Class: Sass::Tree::RuleNode
- Inherits:
-
Node
- Object
- Node
- Sass::Tree::RuleNode
- Defined in:
- /var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb
Overview
A static node reprenting a CSS rule.
Constant Summary
Instance Attribute Summary
- - (Boolean) group_end Whether or not this rule is the last rule in a nested group.
- - (Selector::CommaSequence) parsed_rules The CSS selector for this rule, without any unresolved interpolation but with parent references still intact.
- - (Selector::CommaSequence) resolved_rules The CSS selector for this rule, without any unresolved interpolation or parent references.
-
- (Array<String, Sass::Script::Node>) rule
The CSS selector for this rule, interspersed with Sass::Script::Nodes representing
#{}-interpolation. - - (Array<String>) stack_trace The stack trace.
- - (Fixnum) tabs How deep this rule is indented relative to a base-level rule.
Instance Method Summary
- - (Boolean) =(other) Compares the contents of two rules.
- - add_rules(node) Adds another RuleNode’s rules to this one’s.
- - (Boolean) continued? Whether or not this rule is continued on the next line.
-
- ({#to_s => #to_s}) debug_info
A hash that will be associated with this rule in the CSS document if the
:debug_infooption is enabled. -
- do_extend(extends)
Extends this Rule’s selector with the given
extends. - - filename(filename) If we’ve precached the parsed selector, set the filename on it, too.
- - (RuleNode) initialize(rule) constructor A new instance of RuleNode.
- - line(line) If we’ve precached the parsed selector, set the line on it, too.
Methods inherited from Node
#<<, #balance, #deep_copy, #each, #invisible?, #style, #to_s, #to_sass, #to_scss
Constructor Details
- (RuleNode) initialize(rule)
A new instance of RuleNode
62 63 64 65 66 67 68 |
# File '/var/www/sass-pages/.sass/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
|
Instance Attribute Details
- (Boolean) group_end
Whether or not this rule is the last rule in a nested group. This is only set in a CSS tree.
51 52 53 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 51
def group_end
@group_end
end
|
- (Selector::CommaSequence) parsed_rules
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.
26 27 28 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 26
def parsed_rules
@parsed_rules
end
|
- (Selector::CommaSequence) resolved_rules
The CSS selector for this rule, without any unresolved interpolation or parent references. It’s only set once Tree::Visitors::Cssize has been run.
33 34 35 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 33
def resolved_rules
@resolved_rules
end
|
- (Array<String, Sass::Script::Node>) rule
The CSS selector for this rule, interspersed with Sass::Script::Nodes representing #{}-interpolation. Any adjacent strings will be merged together.
18 19 20 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 18
def rule
@rule
end
|
- (Array<String>) stack_trace
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.
58 59 60 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 58
def stack_trace
@stack_trace
end
|
- (Fixnum) tabs
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
45 46 47 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 45
def tabs
@tabs
end
|
Instance Method Details
- (Boolean) ==(other)
Compares the contents of two rules.
87 88 89 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 87
def ==(other)
self.class == other.class && rule == other.rule && super
end
|
- add_rules(node)
Adds another RuleNode’s rules to this one’s.
94 95 96 97 98 |
# File '/var/www/sass-pages/.sass/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
|
- (Boolean) continued?
Whether or not this rule is continued on the next line
101 102 103 104 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 101
def continued?
last = @rule.last
last.is_a?(String) && last[-1] == ?,
end
|
- ({#to_s => #to_s}) debug_info
A hash that will be associated with this rule in the CSS document if the :debug_info option is enabled. This data is used by e.g. the FireSass Firebug extension.
120 121 122 123 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 120
def debug_info
{:filename => filename && ("file://" + URI.escape(File.expand_path(filename))),
:line => self.line}
end
|
- do_extend(extends)
Extends this Rule’s selector with the given extends.
109 110 111 112 113 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 109
def do_extend(extends)
node = dup
node.resolved_rules = resolved_rules.do_extend(extends)
node
end
|
- filename=(filename)
If we’ve precached the parsed selector, set the filename on it, too.
77 78 79 80 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 77
def filename=(filename)
@parsed_rules.filename = filename if @parsed_rules
super
end
|
- line=(line)
If we’ve precached the parsed selector, set the line on it, too.
71 72 73 74 |
# File '/var/www/sass-pages/.sass/lib/sass/tree/rule_node.rb', line 71
def line=(line)
@parsed_rules.line = line if @parsed_rules
super
end
|