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.
8512
8513
8514
8515
8516
|
# File 'lib/syntax_tree/node.rb', line 8512
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8510
8511
8512
|
# File 'lib/syntax_tree/node.rb', line 8510
def
end
|
#value ⇒ Object
8507
8508
8509
|
# File 'lib/syntax_tree/node.rb', line 8507
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8547
8548
8549
|
# File 'lib/syntax_tree/node.rb', line 8547
def ===(other)
other.is_a?(Period) && value === other.value
end
|
#accept(visitor) ⇒ Object
8518
8519
8520
|
# File 'lib/syntax_tree/node.rb', line 8518
def accept(visitor)
visitor.visit_period(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8522
8523
8524
|
# File 'lib/syntax_tree/node.rb', line 8522
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
|
# File 'lib/syntax_tree/node.rb', line 8526
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
8539
8540
8541
|
# File 'lib/syntax_tree/node.rb', line 8539
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8543
8544
8545
|
# File 'lib/syntax_tree/node.rb', line 8543
def format(q)
q.text(value)
end
|