Class: SyntaxTree::Next
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
-
#arguments ⇒ Object
readonly
- Args
-
the arguments passed to the next keyword.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
Attributes inherited from Node
Instance Method Summary collapse
- #===(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #copy(arguments: nil, location: nil) ⇒ Object
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:) ⇒ Next
constructor
A new instance of Next.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(arguments:, location:) ⇒ Next
Returns a new instance of Next.
7835 7836 7837 7838 7839 |
# File 'lib/syntax_tree/node.rb', line 7835 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments passed to the next keyword
7830 7831 7832 |
# File 'lib/syntax_tree/node.rb', line 7830 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7833 7834 7835 |
# File 'lib/syntax_tree/node.rb', line 7833 def comments @comments end |
Instance Method Details
#===(other) ⇒ Object
7870 7871 7872 |
# File 'lib/syntax_tree/node.rb', line 7870 def ===(other) other.is_a?(Next) && arguments === other.arguments end |
#accept(visitor) ⇒ Object
7841 7842 7843 |
# File 'lib/syntax_tree/node.rb', line 7841 def accept(visitor) visitor.visit_next(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7845 7846 7847 |
# File 'lib/syntax_tree/node.rb', line 7845 def child_nodes [arguments] end |
#copy(arguments: nil, location: nil) ⇒ Object
7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 |
# File 'lib/syntax_tree/node.rb', line 7849 def copy(arguments: nil, location: nil) node = Next.new( arguments: arguments || self.arguments, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
7862 7863 7864 |
# File 'lib/syntax_tree/node.rb', line 7862 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
7866 7867 7868 |
# File 'lib/syntax_tree/node.rb', line 7866 def format(q) FlowControlFormatter.new("next", self).format(q) end |