Class: SyntaxTree::CSS::Selectors::IdSelector

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

Overview

The ID of an element, e.g., #foo www.w3.org/TR/selectors-4/#typedef-id-selector

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(value:) ⇒ IdSelector

Returns a new instance of IdSelector.



83
84
85
# File 'lib/syntax_tree/css/selectors.rb', line 83

def initialize(value:)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



81
82
83
# File 'lib/syntax_tree/css/selectors.rb', line 81

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



87
88
89
# File 'lib/syntax_tree/css/selectors.rb', line 87

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

#child_nodesObject Also known as: deconstruct



91
92
93
# File 'lib/syntax_tree/css/selectors.rb', line 91

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



97
98
99
# File 'lib/syntax_tree/css/selectors.rb', line 97

def deconstruct_keys(keys)
  { value: value }
end