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

#pretty_print, #to_json

Constructor Details

#initialize(parts:, location:, comments: []) ⇒ Args

Returns a new instance of Args.



578
579
580
581
582
# File 'lib/syntax_tree/node.rb', line 578

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



576
577
578
# File 'lib/syntax_tree/node.rb', line 576

def comments
  @comments
end

#partsObject (readonly)

Array[ untyped ]

the arguments that this node wraps



573
574
575
# File 'lib/syntax_tree/node.rb', line 573

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



584
585
586
# File 'lib/syntax_tree/node.rb', line 584

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

#child_nodesObject Also known as: deconstruct



588
589
590
# File 'lib/syntax_tree/node.rb', line 588

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



594
595
596
# File 'lib/syntax_tree/node.rb', line 594

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

#format(q) ⇒ Object



598
599
600
# File 'lib/syntax_tree/node.rb', line 598

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