Class: SyntaxTree::ArgsForward
- Inherits:
-
Object
- Object
- SyntaxTree::ArgsForward
- Defined in:
- lib/syntax_tree.rb
Overview
ArgsForward represents forwarding all kinds of arguments onto another method call.
def request(method, path, **headers, &block); end
def get(...)
request(:GET, ...)
end
def post(...)
request(:POST, ...)
end
In the example above, both the get and post methods are forwarding all of their arguments (positional, keyword, and block) on to the request method. The ArgsForward node appears in both the caller (the request method calls) and the callee (the get and post definitions).
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
- String
-
the value of the operator.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ ArgsForward
constructor
A new instance of ArgsForward.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ ArgsForward
Returns a new instance of ArgsForward.
1321 1322 1323 1324 1325 |
# File 'lib/syntax_tree.rb', line 1321 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
1319 1320 1321 |
# File 'lib/syntax_tree.rb', line 1319 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1316 1317 1318 |
# File 'lib/syntax_tree.rb', line 1316 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the operator
1313 1314 1315 |
# File 'lib/syntax_tree.rb', line 1313 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1327 1328 1329 |
# File 'lib/syntax_tree.rb', line 1327 def child_nodes [] end |
#format(q) ⇒ Object
1331 1332 1333 |
# File 'lib/syntax_tree.rb', line 1331 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 |
# File 'lib/syntax_tree.rb', line 1335 def pretty_print(q) q.group(2, "(", ")") do q.text("args_forward") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1346 1347 1348 1349 1350 1351 1352 1353 |
# File 'lib/syntax_tree.rb', line 1346 def to_json(*opts) { type: :args_forward, value: value, loc: location, cmts: comments }.to_json(*opts) end |