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.



7872
7873
7874
7875
7876
# File 'lib/syntax_tree/node.rb', line 7872

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

Instance Attribute Details

#arguments ⇒ Object (readonly)

[Args] the arguments being passed to the keyword



7867
7868
7869
# File 'lib/syntax_tree/node.rb', line 7867

def arguments
  @arguments
end

#comments ⇒ Object (readonly)

[Array[ Comment | EmbDoc ]] the comments attached to this node



7870
7871
7872
# File 'lib/syntax_tree/node.rb', line 7870

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



7878
7879
7880
# File 'lib/syntax_tree/node.rb', line 7878

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

#child_nodes ⇒ Object Also known as: deconstruct



7882
7883
7884
# File 'lib/syntax_tree/node.rb', line 7882

def child_nodes
  [arguments]
end

#deconstruct_keys(_keys) ⇒ Object



7888
7889
7890
# File 'lib/syntax_tree/node.rb', line 7888

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

#format(q) ⇒ Object



7892
7893
7894
# File 'lib/syntax_tree/node.rb', line 7892

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