Class: SyntaxTree::Next
- Inherits:
-
Object
- Object
- SyntaxTree::Next
- Defined in:
- lib/syntax_tree.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
-
#arguments ⇒ Object
readonly
- Args
-
the arguments passed to the next keyword.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:, comments: []) ⇒ Next
constructor
A new instance of Next.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Next
8749 8750 8751 8752 8753 |
# File 'lib/syntax_tree.rb', line 8749 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments passed to the next keyword
8741 8742 8743 |
# File 'lib/syntax_tree.rb', line 8741 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8747 8748 8749 |
# File 'lib/syntax_tree.rb', line 8747 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
8744 8745 8746 |
# File 'lib/syntax_tree.rb', line 8744 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
8755 8756 8757 |
# File 'lib/syntax_tree.rb', line 8755 def child_nodes [arguments] end |
#format(q) ⇒ Object
8759 8760 8761 |
# File 'lib/syntax_tree.rb', line 8759 def format(q) FlowControlFormatter.new("next", self).format(q) end |
#pretty_print(q) ⇒ Object
8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 |
# File 'lib/syntax_tree.rb', line 8763 def pretty_print(q) q.group(2, "(", ")") do q.text("next") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
8774 8775 8776 8777 8778 |
# File 'lib/syntax_tree.rb', line 8774 def to_json(*opts) { type: :next, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |