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

#construct_keys, #pretty_print, #to_json

Constructor Details

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

Returns a new instance of ArgStar.



711
712
713
714
715
# File 'lib/syntax_tree/node.rb', line 711

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



709
710
711
# File 'lib/syntax_tree/node.rb', line 709

def comments
  @comments
end

#valueObject (readonly)

nil | untyped

the expression being splatted



706
707
708
# File 'lib/syntax_tree/node.rb', line 706

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object



717
718
719
# File 'lib/syntax_tree/node.rb', line 717

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

#child_nodesObject Also known as: deconstruct



721
722
723
# File 'lib/syntax_tree/node.rb', line 721

def child_nodes
  [value]
end

#deconstruct_keys(_keys) ⇒ Object



727
728
729
# File 'lib/syntax_tree/node.rb', line 727

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

#format(q) ⇒ Object



731
732
733
734
# File 'lib/syntax_tree/node.rb', line 731

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