Class: SyntaxTree::ArgsForward
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.
-
#value ⇒ Object
readonly
- String
-
the value of the operator.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
870 871 872 873 874 |
# File 'lib/syntax_tree/node.rb', line 870 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
868 869 870 |
# File 'lib/syntax_tree/node.rb', line 868 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the value of the operator
865 866 867 |
# File 'lib/syntax_tree/node.rb', line 865 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
876 877 878 |
# File 'lib/syntax_tree/node.rb', line 876 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
882 883 884 |
# File 'lib/syntax_tree/node.rb', line 882 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
886 887 888 |
# File 'lib/syntax_tree/node.rb', line 886 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
890 891 892 893 894 895 896 897 898 899 |
# File 'lib/syntax_tree/node.rb', line 890 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
901 902 903 904 905 906 907 908 |
# File 'lib/syntax_tree/node.rb', line 901 def to_json(*opts) { type: :args_forward, value: value, loc: location, cmts: comments }.to_json(*opts) end |