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.



638
639
640
641
642
# File 'lib/syntax_tree/node.rb', line 638

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



636
637
638
# File 'lib/syntax_tree/node.rb', line 636

def comments
  @comments
end

#partsObject (readonly)

Array[ untyped ]

the arguments that this node wraps



633
634
635
# File 'lib/syntax_tree/node.rb', line 633

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



644
645
646
# File 'lib/syntax_tree/node.rb', line 644

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

#child_nodesObject Also known as: deconstruct



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

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



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

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

#format(q) ⇒ Object



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

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