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, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ Period
Returns a new instance of Period.
8421
8422
8423
8424
8425
|
# File 'lib/syntax_tree/node.rb', line 8421
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8419
8420
8421
|
# File 'lib/syntax_tree/node.rb', line 8419
def
@comments
end
|
#value ⇒ Object
8416
8417
8418
|
# File 'lib/syntax_tree/node.rb', line 8416
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
8456
8457
8458
|
# File 'lib/syntax_tree/node.rb', line 8456
def ===(other)
other.is_a?(Period) && value === other.value
end
|
#accept(visitor) ⇒ Object
8427
8428
8429
|
# File 'lib/syntax_tree/node.rb', line 8427
def accept(visitor)
visitor.visit_period(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
8431
8432
8433
|
# File 'lib/syntax_tree/node.rb', line 8431
def child_nodes
[]
end
|
#copy(value: nil, location: nil) ⇒ Object
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
|
# File 'lib/syntax_tree/node.rb', line 8435
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
8448
8449
8450
|
# File 'lib/syntax_tree/node.rb', line 8448
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
8452
8453
8454
|
# File 'lib/syntax_tree/node.rb', line 8452
def format(q)
q.text(value)
end
|