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.
11706
11707
11708
11709
11710
|
# File 'lib/syntax_tree/node.rb', line 11706
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11704
11705
11706
|
# File 'lib/syntax_tree/node.rb', line 11704
def
@comments
end
|
#value ⇒ Object
- Ident
-
the value of this expression
11701
11702
11703
|
# File 'lib/syntax_tree/node.rb', line 11701
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11741
11742
11743
|
# File 'lib/syntax_tree/node.rb', line 11741
def ===(other)
other.is_a?(VCall) && value === other.value
end
|
#accept(visitor) ⇒ Object
11712
11713
11714
|
# File 'lib/syntax_tree/node.rb', line 11712
def accept(visitor)
visitor.visit_vcall(self)
end
|
#access_control? ⇒ Boolean
11745
11746
11747
|
# File 'lib/syntax_tree/node.rb', line 11745
def access_control?
@access_control ||= %w[private protected public].include?(value.value)
end
|
#arity ⇒ Object
11749
11750
11751
|
# File 'lib/syntax_tree/node.rb', line 11749
def arity
0
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11716
11717
11718
|
# File 'lib/syntax_tree/node.rb', line 11716
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
|
# File 'lib/syntax_tree/node.rb', line 11720
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
11733
11734
11735
|
# File 'lib/syntax_tree/node.rb', line 11733
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11737
11738
11739
|
# File 'lib/syntax_tree/node.rb', line 11737
def format(q)
q.format(value)
end
|