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



7939
7940
7941
7942
7943
# File 'lib/syntax_tree/node.rb', line 7939

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



7934
7935
7936
# File 'lib/syntax_tree/node.rb', line 7934

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



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

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



7945
7946
7947
# File 'lib/syntax_tree/node.rb', line 7945

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

#child_nodesObject Also known as: deconstruct



7949
7950
7951
# File 'lib/syntax_tree/node.rb', line 7949

def child_nodes
  [arguments]
end

#deconstruct_keys(_keys) ⇒ Object



7955
7956
7957
# File 'lib/syntax_tree/node.rb', line 7955

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

#format(q) ⇒ Object



7959
7960
7961
# File 'lib/syntax_tree/node.rb', line 7959

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