class Sass::Tree::RuleNode

@see Sass::Tree
A static node representing a CSS rule.

def ==(other)

Returns:
  • (Boolean) - Whether or not this node and the other object

Parameters:
  • other (Object) -- The object to compare with
def ==(other)
  self.class == other.class && rule == other.rule && super
end

def add_rules(node)

Parameters:
  • node (RuleNode) -- The other node
def add_rules(node)
  @rule = Sass::Util.strip_string_array(
    Sass::Util.merge_adjacent_strings(@rule + ["\n"] + node.rule))
  try_to_parse_non_interpolated_rules
end

def continued?

Returns:
  • (Boolean) - Whether or not this rule is continued on the next line
def continued?
  last = @rule.last
  last.is_a?(String) && last[-1] == ?,
end

def debug_info

Returns:
  • ({#to_s => #to_s}) -
def debug_info
  {:filename => filename &&
     ("file://" + URI::DEFAULT_PARSER.escape(File.expand_path(filename))),
   :line => line}
end

def filename=(filename)

If we've precached the parsed selector, set the filename on it, too.
def filename=(filename)
  @parsed_rules.filename = filename if @parsed_rules
  super
end

def initialize(rule, selector_source_range = nil)

Parameters:
  • selector_source_range (Sass::Source::Range) --
  • rule (Array, Sass::Selector::CommaSequence) --
def initialize(rule, selector_source_range = nil)
  if rule.is_a?(Sass::Selector::CommaSequence)
    @rule = [rule.to_s]
    @parsed_rules = rule
  else
    merged = Sass::Util.merge_adjacent_strings(rule)
    @rule = Sass::Util.strip_string_array(merged)
    try_to_parse_non_interpolated_rules
  end
  @selector_source_range = selector_source_range
  @tabs = 0
  super()
end

def invisible?

A rule node is invisible if it has only placeholder selectors.
def invisible?
  resolved_rules.members.all? {|seq| seq.invisible?}
end

def line=(line)

If we've precached the parsed selector, set the line on it, too.
def line=(line)
  @parsed_rules.line = line if @parsed_rules
  super
end

def try_to_parse_non_interpolated_rules

def try_to_parse_non_interpolated_rules
  @parsed_rules = nil
  return unless @rule.all? {|t| t.is_a?(String)}
  # We don't use real filename/line info because we don't have it yet.
  # When we get it, we'll set it on the parsed rules if possible.
  parser = nil
  warnings = Sass.logger.capture do
    parser = Sass::SCSS::StaticParser.new(
      Sass::Util.strip_except_escapes(@rule.join), nil, nil, 1)
    @parsed_rules = parser.parse_selector rescue nil
  end
  # If parsing produces a warning, throw away the result so we can parse
  # later with the real filename info.
  @parsed_rules = nil unless warnings.empty?
end