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.
11675
11676
11677
11678
11679
|
# File 'lib/syntax_tree/node.rb', line 11675
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
11673
11674
11675
|
# File 'lib/syntax_tree/node.rb', line 11673
def
@comments
end
|
#value ⇒ Object
- Ident
-
the value of this expression
11670
11671
11672
|
# File 'lib/syntax_tree/node.rb', line 11670
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
11710
11711
11712
|
# File 'lib/syntax_tree/node.rb', line 11710
def ===(other)
other.is_a?(VCall) && value === other.value
end
|
#accept(visitor) ⇒ Object
11681
11682
11683
|
# File 'lib/syntax_tree/node.rb', line 11681
def accept(visitor)
visitor.visit_vcall(self)
end
|
#access_control? ⇒ Boolean
11714
11715
11716
|
# File 'lib/syntax_tree/node.rb', line 11714
def access_control?
@access_control ||= %w[private protected public].include?(value.value)
end
|
#arity ⇒ Object
11718
11719
11720
|
# File 'lib/syntax_tree/node.rb', line 11718
def arity
0
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
11685
11686
11687
|
# File 'lib/syntax_tree/node.rb', line 11685
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
|
# File 'lib/syntax_tree/node.rb', line 11689
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
11702
11703
11704
|
# File 'lib/syntax_tree/node.rb', line 11702
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
11706
11707
11708
|
# File 'lib/syntax_tree/node.rb', line 11706
def format(q)
q.format(value)
end
|