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.
1271 1272 1273 1274 1275 |
# File 'lib/syntax_tree.rb', line 1271 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
1269 1270 1271 |
# File 'lib/syntax_tree.rb', line 1269 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1266 1267 1268 |
# File 'lib/syntax_tree.rb', line 1266 def location @location end |
#value ⇒ Object (readonly)
- nil | untyped
-
the expression being splatted
1263 1264 1265 |
# File 'lib/syntax_tree.rb', line 1263 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1277 1278 1279 |
# File 'lib/syntax_tree.rb', line 1277 def child_nodes [value] end |
#format(q) ⇒ Object
1281 1282 1283 1284 |
# File 'lib/syntax_tree.rb', line 1281 def format(q) q.text("*") q.format(value) if value end |
#pretty_print(q) ⇒ Object
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
# File 'lib/syntax_tree.rb', line 1286 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
1297 1298 1299 1300 1301 |
# File 'lib/syntax_tree.rb', line 1297 def to_json(*opts) { type: :arg_star, value: value, loc: location, cmts: comments }.to_json( *opts ) end |