Class: Sass::Tree::AtRootNode

Inherits:
Node
  • Object
show all
Defined in:
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.

See Also:

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #filename, #has_children, #line, #options, #source_range

Instance Method Summary collapse

Methods inherited from Node

#<<, #==, #balance, #css, #css_with_sourcemap, #deep_copy, #each, #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 '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_endBoolean

Whether the last child of this node should be considered the end of a group.

Returns:

  • (Boolean)


43
44
45
# File 'lib/sass/tree/at_root_node.rb', line 43

def group_end
  @group_end
end

#queryArray<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"].

Returns:



20
21
22
# File 'lib/sass/tree/at_root_node.rb', line 20

def query
  @query
end

#resolved_typeSymbol

The resolved type of this directive. :with or :without.

Returns:

  • (Symbol)


25
26
27
# File 'lib/sass/tree/at_root_node.rb', line 25

def resolved_type
  @resolved_type
end

#resolved_valueArray<String>

The resolved value of this directive -- a list of directives to either include or exclude.

Returns:

  • (Array<String>)


31
32
33
# File 'lib/sass/tree/at_root_node.rb', line 31

def resolved_value
  @resolved_value
end

#tabsNumber

The number of additional tabs that the contents of this node should be indented.

Returns:

  • (Number)


37
38
39
# File 'lib/sass/tree/at_root_node.rb', line 37

def tabs
  @tabs
end

Instance Method Details

#bubbles?Boolean

Returns:

  • (Boolean)

See Also:



78
79
80
# File '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.

Parameters:

  • directive (String)

Returns:

  • (Boolean)


57
58
59
60
61
62
63
64
65
# File '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.

Parameters:

Returns:

  • (Boolean)


71
72
73
74
75
# File '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