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



618
619
620
621
622
# File 'lib/syntax_tree/node.rb', line 618

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



616
617
618
# File 'lib/syntax_tree/node.rb', line 616

def comments
  @comments
end

#partsObject (readonly)

Array[ untyped ]

the arguments that this node wraps



613
614
615
# File 'lib/syntax_tree/node.rb', line 613

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



624
625
626
# File 'lib/syntax_tree/node.rb', line 624

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

#child_nodesObject Also known as: deconstruct



628
629
630
# File 'lib/syntax_tree/node.rb', line 628

def child_nodes
  parts
end

#deconstruct_keys(_keys) ⇒ Object



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

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

#format(q) ⇒ Object



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

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