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.
8576
8577
8578
8579
8580
|
# File 'lib/syntax_tree/node.rb', line 8576
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8574
8575
8576
|
# File 'lib/syntax_tree/node.rb', line 8574
def
@comments
end
|
#value ⇒ Object
8571
8572
8573
|
# File 'lib/syntax_tree/node.rb', line 8571
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8611
8612
8613
|
# File 'lib/syntax_tree/node.rb', line 8611
def ===(other)
other.is_a?(Period) && value === other.value
end
|
#accept(visitor) ⇒ Object
8582
8583
8584
|
# File 'lib/syntax_tree/node.rb', line 8582
def accept(visitor)
visitor.visit_period(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8586
8587
8588
|
# File 'lib/syntax_tree/node.rb', line 8586
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
|
# File 'lib/syntax_tree/node.rb', line 8590
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
8603
8604
8605
|
# File 'lib/syntax_tree/node.rb', line 8603
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8607
8608
8609
|
# File 'lib/syntax_tree/node.rb', line 8607
def format(q)
q.text(value)
end
|