Class: SyntaxTree::Period
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Period
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Period represents the use of the .
operator. It is usually found in method calls.
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ Period
Returns a new instance of Period.
8560
8561
8562
8563
8564
|
# File 'lib/syntax_tree/node.rb', line 8560
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8558
8559
8560
|
# File 'lib/syntax_tree/node.rb', line 8558
def
@comments
end
|
#value ⇒ Object
8555
8556
8557
|
# File 'lib/syntax_tree/node.rb', line 8555
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8595
8596
8597
|
# File 'lib/syntax_tree/node.rb', line 8595
def ===(other)
other.is_a?(Period) && value === other.value
end
|
#accept(visitor) ⇒ Object
8566
8567
8568
|
# File 'lib/syntax_tree/node.rb', line 8566
def accept(visitor)
visitor.visit_period(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8570
8571
8572
|
# File 'lib/syntax_tree/node.rb', line 8570
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
|
# File 'lib/syntax_tree/node.rb', line 8574
def copy(value: nil, location: nil)
node =
Period.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
8587
8588
8589
|
# File 'lib/syntax_tree/node.rb', line 8587
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8591
8592
8593
|
# File 'lib/syntax_tree/node.rb', line 8591
def format(q)
q.text(value)
end
|