Class: SyntaxTree::VCall
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::VCall
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
VCall represent any plain named object with Ruby that could be either a local variable or a method call.
variable
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:) ⇒ VCall
Returns a new instance of VCall.
11581
11582
11583
11584
11585
|
# File 'lib/syntax_tree/node.rb', line 11581
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11579
11580
11581
|
# File 'lib/syntax_tree/node.rb', line 11579
def
end
|
#value ⇒ Object
- Ident
-
the value of this expression
11576
11577
11578
|
# File 'lib/syntax_tree/node.rb', line 11576
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11616
11617
11618
|
# File 'lib/syntax_tree/node.rb', line 11616
def ===(other)
other.is_a?(VCall) && value === other.value
end
|
#accept(visitor) ⇒ Object
11587
11588
11589
|
# File 'lib/syntax_tree/node.rb', line 11587
def accept(visitor)
visitor.visit_vcall(self)
end
|
#access_control? ⇒ Boolean
11620
11621
11622
|
# File 'lib/syntax_tree/node.rb', line 11620
def access_control?
@access_control ||= %w[private protected public].include?(value.value)
end
|
#arity ⇒ Object
11624
11625
11626
|
# File 'lib/syntax_tree/node.rb', line 11624
def arity
0
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11591
11592
11593
|
# File 'lib/syntax_tree/node.rb', line 11591
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
|
# File 'lib/syntax_tree/node.rb', line 11595
def copy(value: nil, location: nil)
node =
VCall.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
11608
11609
11610
|
# File 'lib/syntax_tree/node.rb', line 11608
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11612
11613
11614
|
# File 'lib/syntax_tree/node.rb', line 11612
def format(q)
q.format(value)
end
|