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.



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

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



591
592
593
# File 'lib/syntax_tree/node.rb', line 591

def comments
  @comments
end

#partsObject (readonly)

Array[ untyped ]

the arguments that this node wraps



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

def parts
  @parts
end

Instance Method Details

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



603
604
605
# File 'lib/syntax_tree/node.rb', line 603

def child_nodes
  parts
end

#deconstruct_keys(keys) ⇒ Object



609
610
611
# File 'lib/syntax_tree/node.rb', line 609

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

#format(q) ⇒ Object



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

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