Class: SyntaxTree::ArgStar

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

Overview

Star represents using a splat operator on an expression.

method(*arguments)

Instance Attribute Summary collapse

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#pretty_print, #to_json

Constructor Details

#initialize(value:, location:, comments: []) ⇒ ArgStar

Returns a new instance of ArgStar.



666
667
668
669
670
# File 'lib/syntax_tree/node.rb', line 666

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



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

def comments
  @comments
end

#valueObject (readonly)

nil | untyped

the expression being splatted



661
662
663
# File 'lib/syntax_tree/node.rb', line 661

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



676
677
678
# File 'lib/syntax_tree/node.rb', line 676

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object



682
683
684
# File 'lib/syntax_tree/node.rb', line 682

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

#format(q) ⇒ Object



686
687
688
689
# File 'lib/syntax_tree/node.rb', line 686

def format(q)
  q.text("*")
  q.format(value) if value
end