Class: Sass::Tree::AtRootNode

Inherits:
Node
  • Object
show all
Defined in:
/Users/ceppstei/Projects/sass-lang/.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.

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

- (AtRootNode) initialize(query = nil)

Returns a new instance of AtRootNode



45
46
47
48
49
# File '/Users/ceppstei/Projects/sass-lang/.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

- (Boolean) group_end

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

Returns:

  • (Boolean)


43
44
45
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb', line 43

def group_end
  @group_end
end

- (Array<String, Sass::Script::Tree::Node>) query

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, will automatically be set to :without and will automatically be set to ["rule"].

Returns:



20
21
22
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb', line 20

def query
  @query
end

- (Symbol) resolved_type

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

Returns:

  • (Symbol)


25
26
27
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb', line 25

def resolved_type
  @resolved_type
end

- (Array<String>) resolved_value

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

Returns:

  • (Array<String>)


31
32
33
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb', line 31

def resolved_value
  @resolved_value
end

- (Number) tabs

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

Returns:

  • (Number)


37
38
39
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb', line 37

def tabs
  @tabs
end

Instance Method Details

- (Boolean) bubbles?

Returns:

  • (Boolean)

See Also:



78
79
80
# File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/tree/at_root_node.rb', line 78

def bubbles?
  true
end

- (Boolean) exclude?(directive)

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 '/Users/ceppstei/Projects/sass-lang/.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

- (Boolean) exclude_node?(node)

Returns whether the given node is excluded by this node.

Parameters:

Returns:

  • (Boolean)


71
72
73
74
75
# File '/Users/ceppstei/Projects/sass-lang/.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