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.
-
#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 (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.
903 904 905 906 907 |
# File 'lib/syntax_tree/node.rb', line 903 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
901 902 903 |
# File 'lib/syntax_tree/node.rb', line 901 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
898 899 900 |
# File 'lib/syntax_tree/node.rb', line 898 def location @location end |
#value ⇒ Object (readonly)
- String
-
the value of the operator
895 896 897 |
# File 'lib/syntax_tree/node.rb', line 895 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
909 910 911 |
# File 'lib/syntax_tree/node.rb', line 909 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
915 916 917 |
# File 'lib/syntax_tree/node.rb', line 915 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
919 920 921 |
# File 'lib/syntax_tree/node.rb', line 919 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
923 924 925 926 927 928 929 930 931 932 |
# File 'lib/syntax_tree/node.rb', line 923 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
934 935 936 937 938 939 940 941 |
# File 'lib/syntax_tree/node.rb', line 934 def to_json(*opts) { type: :args_forward, value: value, loc: location, cmts: comments }.to_json(*opts) end |