Class: SyntaxTree::CSS::StyleRule

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

Overview

A style rule is a qualified rule that associates a selector list with a list of property declarations and possibly a list of nested rules. www.w3.org/TR/css-syntax-3/#style-rule

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(selectors:, declarations:, location:) ⇒ StyleRule

Returns a new instance of StyleRule.



846
847
848
849
850
# File 'lib/syntax_tree/css/nodes.rb', line 846

def initialize(selectors:, declarations:, location:)
  @selectors = selectors
  @declarations = declarations
  @location = location
end

Instance Attribute Details

#declarationsObject (readonly)

Returns the value of attribute declarations.



844
845
846
# File 'lib/syntax_tree/css/nodes.rb', line 844

def declarations
  @declarations
end

#locationObject (readonly)

Returns the value of attribute location.



844
845
846
# File 'lib/syntax_tree/css/nodes.rb', line 844

def location
  @location
end

#selectorsObject (readonly)

Returns the value of attribute selectors.



844
845
846
# File 'lib/syntax_tree/css/nodes.rb', line 844

def selectors
  @selectors
end

Instance Method Details

#accept(visitor) ⇒ Object



852
853
854
# File 'lib/syntax_tree/css/nodes.rb', line 852

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

#child_nodesObject Also known as: deconstruct



856
857
858
# File 'lib/syntax_tree/css/nodes.rb', line 856

def child_nodes
  [*selectors, *declarations]
end

#deconstruct_keys(keys) ⇒ Object



862
863
864
# File 'lib/syntax_tree/css/nodes.rb', line 862

def deconstruct_keys(keys)
  { selectors: selectors, declarations: declarations, location: location }
end