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.
935
936
937
938
939
|
# File 'lib/syntax_tree/node.rb', line 935
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
933
934
935
|
# File 'lib/syntax_tree/node.rb', line 933
def
@comments
end
|
#value ⇒ Object
- nil | untyped
-
the expression being splatted
930
931
932
|
# File 'lib/syntax_tree/node.rb', line 930
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
971
972
973
|
# File 'lib/syntax_tree/node.rb', line 971
def ===(other)
other.is_a?(ArgStar) && value === other.value
end
|
#accept(visitor) ⇒ Object
941
942
943
|
# File 'lib/syntax_tree/node.rb', line 941
def accept(visitor)
visitor.visit_arg_star(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
945
946
947
|
# File 'lib/syntax_tree/node.rb', line 945
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
949
950
951
952
953
954
955
956
957
958
|
# File 'lib/syntax_tree/node.rb', line 949
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
962
963
964
|
# File 'lib/syntax_tree/node.rb', line 962
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
966
967
968
969
|
# File 'lib/syntax_tree/node.rb', line 966
def format(q)
q.text("*")
q.format(value) if value
end
|