Class: SyntaxTree::Next

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

Overview

Next represents using the next keyword.

next

The next keyword can also optionally be called with an argument:

next value

next can even be called with multiple arguments, but only if parentheses are omitted, as in:

next first, second, third

If a single value is being given, parentheses can be used, as in:

next(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: []) ⇒ Next

Returns a new instance of Next.



5768
5769
5770
5771
5772
# File 'lib/syntax_tree/node.rb', line 5768

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

Instance Attribute Details

#argumentsObject (readonly)

Args

the arguments passed to the next keyword



5763
5764
5765
# File 'lib/syntax_tree/node.rb', line 5763

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



5766
5767
5768
# File 'lib/syntax_tree/node.rb', line 5766

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



5774
5775
5776
# File 'lib/syntax_tree/node.rb', line 5774

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

#child_nodesObject Also known as: deconstruct



5778
5779
5780
# File 'lib/syntax_tree/node.rb', line 5778

def child_nodes
  [arguments]
end

#deconstruct_keys(keys) ⇒ Object



5784
5785
5786
# File 'lib/syntax_tree/node.rb', line 5784

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

#format(q) ⇒ Object



5788
5789
5790
# File 'lib/syntax_tree/node.rb', line 5788

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