Parent

Class/Module Index [+]

Quicksearch

Sass::Tree::RuleNode

A static node reprenting a CSS rule.

@see Sass::Tree

Constants

PARENT

The character used to include the parent selector

Attributes

group_end[RW]

Whether or not this rule is the last rule in a nested group. This is only set in a CSS tree.

@return [Boolean]

parsed_rules[RW]

The CSS selector for this rule, without any unresolved interpolation but with parent references still intact. It's only set once {Tree::Node#perform} has been called.

@return [Selector::CommaSequence]

resolved_rules[RW]

The CSS selector for this rule, without any unresolved interpolation or parent references. It's only set once {Tree::Visitors::Cssize} has been run.

@return [Selector::CommaSequence]

rule[RW]

The CSS selector for this rule, interspersed with {Sass::Script::Node}s representing `#{}`-interpolation. Any adjacent strings will be merged together.

@return [Array<String, Sass::Script::Node>]

stack_trace[RW]

The stack trace. This is only readable in a CSS tree as it is written during the perform step and only when the :trace_selectors option is set.

@return [Array<String>]

tabs[RW]

How deep this rule is indented relative to a base-level rule. This is only greater than 0 in the case that:

  • This node is in a CSS tree

  • The style is :nested

  • This is a child rule of another rule

  • The parent rule has properties, and thus will be rendered

@return [Fixnum]

Public Class Methods

new(rule) click to toggle source

@param rule [Array<String, Sass::Script::Node>]

The CSS rule. See \{#rule}
# File lib/sass/tree/rule_node.rb, line 62
def initialize(rule)
  merged = Sass::Util.merge_adjacent_strings(rule)
  @rule = Sass::Util.strip_string_array(merged)
  @tabs = 0
  try_to_parse_non_interpolated_rules
  super()
end

Public Instance Methods

==(other) click to toggle source

Compares the contents of two rules.

@param other [Object] The object to compare with @return [Boolean] Whether or not this node and the other object

are the same
# File lib/sass/tree/rule_node.rb, line 87
def ==(other)
  self.class == other.class && rule == other.rule && super
end
add_rules(node) click to toggle source

Adds another {RuleNode}'s rules to this one's.

@param node [RuleNode] The other node

# File lib/sass/tree/rule_node.rb, line 94
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
continued?() click to toggle source

@return [Boolean] Whether or not this rule is continued on the next line

# File lib/sass/tree/rule_node.rb, line 101
def continued?
  last = @rule.last
  last.is_a?(String) && last[-1] == ,,
end
debug_info() click to toggle source

A hash that will be associated with this rule in the CSS document if the {file:SASS_REFERENCE.md#debug_info-option `:debug_info` option} is enabled. This data is used by e.g. [the FireSass Firebug extension](addons.mozilla.org/en-US/firefox/addon/103988).

@return [{to_s => to_s}]

# File lib/sass/tree/rule_node.rb, line 111
def debug_info
  {:filename => filename && ("file://" + URI.escape(File.expand_path(filename))),
   :line => self.line}
end
filename=(filename) click to toggle source

If we've precached the parsed selector, set the filename on it, too.

# File lib/sass/tree/rule_node.rb, line 77
def filename=(filename)
  @parsed_rules.filename = filename if @parsed_rules
  super
end
invisible?() click to toggle source

A rule node is invisible if it has only placeholder selectors.

# File lib/sass/tree/rule_node.rb, line 117
def invisible?
  resolved_rules.members.all? {|seq| seq.has_placeholder?}
end
line=(line) click to toggle source

If we've precached the parsed selector, set the line on it, too.

# File lib/sass/tree/rule_node.rb, line 71
def line=(line)
  @parsed_rules.line = line if @parsed_rules
  super
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.