Class: SyntaxTree::ArgStar
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ArgStar
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Star represents using a splat operator on an expression.
method(*arguments)
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:) ⇒ ArgStar
Returns a new instance of ArgStar.
916
917
918
919
920
|
# File 'lib/syntax_tree/node.rb', line 916
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
914
915
916
|
# File 'lib/syntax_tree/node.rb', line 914
def
@comments
end
|
#value ⇒ Object
- nil | untyped
-
the expression being splatted
911
912
913
|
# File 'lib/syntax_tree/node.rb', line 911
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
952
953
954
|
# File 'lib/syntax_tree/node.rb', line 952
def ===(other)
other.is_a?(ArgStar) && value === other.value
end
|
#accept(visitor) ⇒ Object
922
923
924
|
# File 'lib/syntax_tree/node.rb', line 922
def accept(visitor)
visitor.visit_arg_star(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
926
927
928
|
# File 'lib/syntax_tree/node.rb', line 926
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
930
931
932
933
934
935
936
937
938
939
|
# File 'lib/syntax_tree/node.rb', line 930
def copy(value: nil, location: nil)
node =
ArgStar.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
943
944
945
|
# File 'lib/syntax_tree/node.rb', line 943
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
947
948
949
950
|
# File 'lib/syntax_tree/node.rb', line 947
def format(q)
q.text("*")
q.format(value) if value
end
|