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

#construct_keys, #pretty_print, #to_json

Constructor Details

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

Returns a new instance of Next.



6579
6580
6581
6582
6583
# File 'lib/syntax_tree/node.rb', line 6579

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



6574
6575
6576
# File 'lib/syntax_tree/node.rb', line 6574

def arguments
  @arguments
end

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



6577
6578
6579
# File 'lib/syntax_tree/node.rb', line 6577

def comments
  @comments
end

Instance Method Details

#accept(visitor) ⇒ Object



6585
6586
6587
# File 'lib/syntax_tree/node.rb', line 6585

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

#child_nodesObject Also known as: deconstruct



6589
6590
6591
# File 'lib/syntax_tree/node.rb', line 6589

def child_nodes
  [arguments]
end

#deconstruct_keys(_keys) ⇒ Object



6595
6596
6597
# File 'lib/syntax_tree/node.rb', line 6595

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

#format(q) ⇒ Object



6599
6600
6601
# File 'lib/syntax_tree/node.rb', line 6599

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