Class: SyntaxTree::ArgStar
- Inherits:
-
Object
- Object
- SyntaxTree::ArgStar
- Defined in:
- lib/syntax_tree.rb
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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- nil | untyped
-
the expression being splatted.
Instance Method Summary collapse
- #child_nodes ⇒ 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.
1201 1202 1203 1204 1205 |
# File 'lib/syntax_tree.rb', line 1201 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
1199 1200 1201 |
# File 'lib/syntax_tree.rb', line 1199 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1196 1197 1198 |
# File 'lib/syntax_tree.rb', line 1196 def location @location end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being splatted
1193 1194 1195 |
# File 'lib/syntax_tree.rb', line 1193 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1207 1208 1209 |
# File 'lib/syntax_tree.rb', line 1207 def child_nodes [value] end |
#format(q) ⇒ Object
1211 1212 1213 1214 |
# File 'lib/syntax_tree.rb', line 1211 def format(q) q.text("*") q.format(value) if value end |
#pretty_print(q) ⇒ Object
1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/syntax_tree.rb', line 1216 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
1227 1228 1229 1230 1231 |
# File 'lib/syntax_tree.rb', line 1227 def to_json(*opts) { type: :arg_star, value: value, loc: location, cmts: comments }.to_json( *opts ) end |