Class: SyntaxTree::CSS::AtRule

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/css/nodes.rb

Overview

A rule that starts with an at-keyword and then accepts arbitrary tokens. A common example is an @media rule. www.w3.org/TR/css-syntax-3/#at-rule

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(name:, prelude:, block:, location:) ⇒ AtRule

Returns a new instance of AtRule.



71
72
73
74
75
76
# File 'lib/syntax_tree/css/nodes.rb', line 71

def initialize(name:, prelude:, block:, location:)
  @name = name
  @prelude = prelude
  @block = block
  @location = location
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



69
70
71
# File 'lib/syntax_tree/css/nodes.rb', line 69

def block
  @block
end

#locationObject (readonly)

Returns the value of attribute location.



69
70
71
# File 'lib/syntax_tree/css/nodes.rb', line 69

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



69
70
71
# File 'lib/syntax_tree/css/nodes.rb', line 69

def name
  @name
end

#preludeObject (readonly)

Returns the value of attribute prelude.



69
70
71
# File 'lib/syntax_tree/css/nodes.rb', line 69

def prelude
  @prelude
end

Instance Method Details

#accept(visitor) ⇒ Object



78
79
80
# File 'lib/syntax_tree/css/nodes.rb', line 78

def accept(visitor)
  visitor.visit_at_rule(self)
end

#child_nodesObject Also known as: deconstruct



82
83
84
# File 'lib/syntax_tree/css/nodes.rb', line 82

def child_nodes
  [*prelude, block].compact
end

#deconstruct_keys(keys) ⇒ Object



88
89
90
# File 'lib/syntax_tree/css/nodes.rb', line 88

def deconstruct_keys(keys)
  { name: name, prelude: prelude, block: block, location: location }
end