Class: SyntaxTree::Return

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

Overview

Return represents using the return keyword with arguments.

return value

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(arguments:, location:, comments: []) ⇒ Return

Returns a new instance of Return.



7840
7841
7842
7843
7844
# File 'lib/syntax_tree/node.rb', line 7840

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

Instance Attribute Details

#argumentsObject (readonly)

Args

the arguments being passed to the keyword



7835
7836
7837
# File 'lib/syntax_tree/node.rb', line 7835

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



7838
7839
7840
# File 'lib/syntax_tree/node.rb', line 7838

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



7846
7847
7848
# File 'lib/syntax_tree/node.rb', line 7846

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

#child_nodesObject Also known as: deconstruct



7850
7851
7852
# File 'lib/syntax_tree/node.rb', line 7850

def child_nodes
  [arguments]
end

#deconstruct_keys(_keys) ⇒ Object



7856
7857
7858
# File 'lib/syntax_tree/node.rb', line 7856

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

#format(q) ⇒ Object



7860
7861
7862
# File 'lib/syntax_tree/node.rb', line 7860

def format(q)
  FlowControlFormatter.new("return", self).format(q)
end