Class: Parser::AST::ArgumentsNode

Inherits:
Object
  • Object
show all
Defined in:
lib/synvert/core/node_ext.rb

Overview

ArgumentsNode allows to handle all args as one node or handle all args as an array.

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ ArgumentsNode

Initialize

Parameters:



7
8
9
# File 'lib/synvert/core/node_ext.rb', line 7

def initialize(node)
  @node = node
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

If args node responds method itself, call method on args node. If args children (array) responds method, call method on args children. Otherwise raise method missing error.



14
15
16
17
18
19
20
21
22
# File 'lib/synvert/core/node_ext.rb', line 14

def method_missing(meth, *args, &block)
  if @node.respond_to?(meth)
    @node.send meth, *args, &block
  elsif @node.children.respond_to?(meth)
    @node.children.send meth, *args, &block
  else
    super
  end
end