Class: SyntaxTree::ArgStar
Overview
Star represents using a splat operator on an expression.
method(*arguments)
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- nil | untyped
-
the expression being splatted.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ ArgStar
constructor
A new instance of ArgStar.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ ArgStar
Returns a new instance of ArgStar.
807 808 809 810 811 |
# File 'lib/syntax_tree/node.rb', line 807 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
805 806 807 |
# File 'lib/syntax_tree/node.rb', line 805 def comments @comments end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being splatted
802 803 804 |
# File 'lib/syntax_tree/node.rb', line 802 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
813 814 815 |
# File 'lib/syntax_tree/node.rb', line 813 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
819 820 821 |
# File 'lib/syntax_tree/node.rb', line 819 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
823 824 825 826 |
# File 'lib/syntax_tree/node.rb', line 823 def format(q) q.text("*") q.format(value) if value end |
#pretty_print(q) ⇒ Object
828 829 830 831 832 833 834 835 836 837 |
# File 'lib/syntax_tree/node.rb', line 828 def pretty_print(q) q.group(2, "(", ")") do q.text("arg_star") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
839 840 841 842 843 |
# File 'lib/syntax_tree/node.rb', line 839 def to_json(*opts) { type: :arg_star, value: value, loc: location, cmts: comments }.to_json( *opts ) end |