Class: SyntaxTree::Args

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

Args represents a list of arguments being passed to a method call or array literal.

method(first, second, third)

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(parts:, location:, comments: []) ⇒ Args

Returns a new instance of Args.



653
654
655
656
657
# File 'lib/syntax_tree/node.rb', line 653

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



651
652
653
# File 'lib/syntax_tree/node.rb', line 651

def comments
  @comments
end

#partsObject (readonly)

Array[ untyped ]

the arguments that this node wraps



648
649
650
# File 'lib/syntax_tree/node.rb', line 648

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



659
660
661
# File 'lib/syntax_tree/node.rb', line 659

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

#child_nodesObject Also known as: deconstruct



663
664
665
# File 'lib/syntax_tree/node.rb', line 663

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



669
670
671
# File 'lib/syntax_tree/node.rb', line 669

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

#format(q) ⇒ Object



673
674
675
# File 'lib/syntax_tree/node.rb', line 673

def format(q)
  q.seplist(parts) { |part| q.format(part) }
end