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, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(value:, location:) ⇒ VCall
Returns a new instance of VCall.
11742
11743
11744
11745
11746
|
# File 'lib/syntax_tree/node.rb', line 11742
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11740
11741
11742
|
# File 'lib/syntax_tree/node.rb', line 11740
def
end
|
#value ⇒ Object
- Ident
-
the value of this expression
11737
11738
11739
|
# File 'lib/syntax_tree/node.rb', line 11737
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11777
11778
11779
|
# File 'lib/syntax_tree/node.rb', line 11777
def ===(other)
other.is_a?(VCall) && value === other.value
end
|
#accept(visitor) ⇒ Object
11748
11749
11750
|
# File 'lib/syntax_tree/node.rb', line 11748
def accept(visitor)
visitor.visit_vcall(self)
end
|
#access_control? ⇒ Boolean
11781
11782
11783
|
# File 'lib/syntax_tree/node.rb', line 11781
def access_control?
@access_control ||= %w[private protected public].include?(value.value)
end
|
#arity ⇒ Object
11785
11786
11787
|
# File 'lib/syntax_tree/node.rb', line 11785
def arity
0
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11752
11753
11754
|
# File 'lib/syntax_tree/node.rb', line 11752
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
|
# File 'lib/syntax_tree/node.rb', line 11756
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
11769
11770
11771
|
# File 'lib/syntax_tree/node.rb', line 11769
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11773
11774
11775
|
# File 'lib/syntax_tree/node.rb', line 11773
def format(q)
q.format(value)
end
|