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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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
Returns a new instance of Next.
7529 7530 7531 7532 7533 |
# File 'lib/syntax_tree/node.rb', line 7529 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
7521 7522 7523 |
# File 'lib/syntax_tree/node.rb', line 7521 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7527 7528 7529 |
# File 'lib/syntax_tree/node.rb', line 7527 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7524 7525 7526 |
# File 'lib/syntax_tree/node.rb', line 7524 def location @location end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
7535 7536 7537 |
# File 'lib/syntax_tree/node.rb', line 7535 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
7541 7542 7543 |
# File 'lib/syntax_tree/node.rb', line 7541 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
7545 7546 7547 |
# File 'lib/syntax_tree/node.rb', line 7545 def format(q) FlowControlFormatter.new("next", self).format(q) end |
#pretty_print(q) ⇒ Object
7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 |
# File 'lib/syntax_tree/node.rb', line 7549 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
7560 7561 7562 7563 7564 |
# File 'lib/syntax_tree/node.rb', line 7560 def to_json(*opts) { type: :next, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |