Class: SyntaxTree::ArgsForward

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.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

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ ArgsForward

Returns a new instance of ArgsForward.



761
762
763
764
765
# File 'lib/syntax_tree/node.rb', line 761

def initialize(value:, location:, comments: [])
  @value = value
  @location = location
  @comments = comments
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



759
760
761
# File 'lib/syntax_tree/node.rb', line 759

def comments
  @comments
end

#valueObject (readonly)

String

the value of the operator



756
757
758
# File 'lib/syntax_tree/node.rb', line 756

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



767
768
769
# File 'lib/syntax_tree/node.rb', line 767

def accept(visitor)
  visitor.visit_args_forward(self)
end

#child_nodesObject Also known as: deconstruct



771
772
773
# File 'lib/syntax_tree/node.rb', line 771

def child_nodes
  []
end

#deconstruct_keys(_keys) ⇒ Object



777
778
779
# File 'lib/syntax_tree/node.rb', line 777

def deconstruct_keys(_keys)
  { value: value, location: location, comments: comments }
end

#format(q) ⇒ Object



781
782
783
# File 'lib/syntax_tree/node.rb', line 781

def format(q)
  q.text(value)
end