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.



7922
7923
7924
7925
7926
# File 'lib/syntax_tree/node.rb', line 7922

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



7917
7918
7919
# File 'lib/syntax_tree/node.rb', line 7917

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



7920
7921
7922
# File 'lib/syntax_tree/node.rb', line 7920

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



7928
7929
7930
# File 'lib/syntax_tree/node.rb', line 7928

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

#child_nodesObject Also known as: deconstruct



7932
7933
7934
# File 'lib/syntax_tree/node.rb', line 7932

def child_nodes
  [arguments]
end

#deconstruct_keys(_keys) ⇒ Object



7938
7939
7940
# File 'lib/syntax_tree/node.rb', line 7938

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

#format(q) ⇒ Object



7942
7943
7944
# File 'lib/syntax_tree/node.rb', line 7942

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