Class: Sass::Tree::AtRootNode
- Inherits:
-
Node
- Object
- Node
- Sass::Tree::AtRootNode
- Defined in:
- .ruby-sass/lib/sass/tree/at_root_node.rb
Overview
A dynamic node representing an `@at-root` directive.
An `@at-root` directive with a selector is converted to an AtRootNode containing a RuleNode at parse time.
Instance Attribute Summary (collapse)
-
#group_end ⇒ Boolean
Whether the last child of this node should be considered the end of a group.
-
#query ⇒ Array<String, Sass::Script::Tree::Node>
The query for this node (e.g. `(without: media)`), interspersed with Script::Tree::Nodes representing `#{}`-interpolation.
-
#resolved_type ⇒ Symbol
The resolved type of this directive.
-
#resolved_value ⇒ Array<String>
The resolved value of this directive – a list of directives to either include or exclude.
-
#tabs ⇒ Number
The number of additional tabs that the contents of this node should be indented.
Attributes inherited from Node
#children, #filename, #has_children, #line, #options, #source_range
Instance Method Summary (collapse)
- #bubbles? ⇒ Boolean
-
#exclude?(directive) ⇒ Boolean
Returns whether or not the given directive is excluded by this node.
-
#exclude_node?(node) ⇒ Boolean
Returns whether the given node is excluded by this node.
-
#initialize(query = nil) ⇒ AtRootNode
constructor
A new instance of AtRootNode.
Methods inherited from Node
#<<, #==, #css, #css_with_sourcemap, #deep_copy, #each, inherited, #inspect, #invisible?, #style, #to_sass, #to_scss
Constructor Details
#initialize(query = nil) ⇒ AtRootNode
Returns a new instance of AtRootNode
45 46 47 48 49 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 45 def initialize(query = nil) super() @query = Sass::Util.strip_string_array(Sass::Util.merge_adjacent_strings(query)) if query @tabs = 0 end |
Constructor Details
#initialize(query = nil) ⇒ AtRootNode
Returns a new instance of AtRootNode
45 46 47 48 49 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 45 def initialize(query = nil) super() @query = Sass::Util.strip_string_array(Sass::Util.merge_adjacent_strings(query)) if query @tabs = 0 end |
Instance Attribute Details
#group_end ⇒ Boolean
Whether the last child of this node should be considered the end of a group.
43 44 45 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 43 def group_end @group_end end |
#query ⇒ Array<String, Sass::Script::Tree::Node>
The query for this node (e.g. `(without: media)`), interspersed with Script::Tree::Nodes representing `#{}`-interpolation. Any adjacent strings will be merged together.
This will be nil if the directive didn't have a query. In this case, #resolved_type will automatically be set to `:without` and #resolved_rule will automatically be set to `[“rule”]`.
20 21 22 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 20 def query @query end |
#resolved_type ⇒ Symbol
The resolved type of this directive. `:with` or `:without`.
25 26 27 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 25 def resolved_type @resolved_type end |
#resolved_value ⇒ Array<String>
The resolved value of this directive – a list of directives to either include or exclude.
31 32 33 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 31 def resolved_value @resolved_value end |
#tabs ⇒ Number
The number of additional tabs that the contents of this node should be indented.
37 38 39 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 37 def tabs @tabs end |
Instance Method Details
#bubbles? ⇒ Boolean
78 79 80 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 78 def bubbles? true end |
#exclude?(directive) ⇒ Boolean
Returns whether or not the given directive is excluded by this node. `directive` may be “rule”, which indicates whether normal CSS rules should be excluded.
57 58 59 60 61 62 63 64 65 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 57 def exclude?(directive) if resolved_type == :with return false if resolved_value.include?('all') !resolved_value.include?(directive) else # resolved_type == :without return true if resolved_value.include?('all') resolved_value.include?(directive) end end |
#exclude_node?(node) ⇒ Boolean
Returns whether the given node is excluded by this node.
71 72 73 74 75 |
# File '.ruby-sass/lib/sass/tree/at_root_node.rb', line 71 def exclude_node?(node) return exclude?(node.name.gsub(/^@/, '')) if node.is_a?(Sass::Tree::DirectiveNode) return exclude?('keyframes') if node.is_a?(Sass::Tree::KeyframeRuleNode) exclude?('rule') && node.is_a?(Sass::Tree::RuleNode) end |