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

#pretty_print, #to_json

Constructor Details

#initialize(arguments:, location:, comments: []) ⇒ Return

Returns a new instance of Return.



7119
7120
7121
7122
7123
# File 'lib/syntax_tree/node.rb', line 7119

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



7114
7115
7116
# File 'lib/syntax_tree/node.rb', line 7114

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



7117
7118
7119
# File 'lib/syntax_tree/node.rb', line 7117

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



7125
7126
7127
# File 'lib/syntax_tree/node.rb', line 7125

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

#child_nodesObject Also known as: deconstruct



7129
7130
7131
# File 'lib/syntax_tree/node.rb', line 7129

def child_nodes
  [arguments]
end

#deconstruct_keys(keys) ⇒ Object



7135
7136
7137
# File 'lib/syntax_tree/node.rb', line 7135

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

#format(q) ⇒ Object



7139
7140
7141
# File 'lib/syntax_tree/node.rb', line 7139

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