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, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(arguments:, location:) ⇒ Next
Returns a new instance of Next.
7956 7957 7958 7959 7960 |
# File 'lib/syntax_tree/node.rb', line 7956 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments passed to the next keyword
7951 7952 7953 |
# File 'lib/syntax_tree/node.rb', line 7951 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7954 7955 7956 |
# File 'lib/syntax_tree/node.rb', line 7954 def comments @comments end |
Instance Method Details
#===(other) ⇒ Object
7991 7992 7993 |
# File 'lib/syntax_tree/node.rb', line 7991 def ===(other) other.is_a?(Next) && arguments === other.arguments end |
#accept(visitor) ⇒ Object
7962 7963 7964 |
# File 'lib/syntax_tree/node.rb', line 7962 def accept(visitor) visitor.visit_next(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
7966 7967 7968 |
# File 'lib/syntax_tree/node.rb', line 7966 def child_nodes [arguments] end |
#copy(arguments: nil, location: nil) ⇒ Object
7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 |
# File 'lib/syntax_tree/node.rb', line 7970 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
7983 7984 7985 |
# File 'lib/syntax_tree/node.rb', line 7983 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
7987 7988 7989 |
# File 'lib/syntax_tree/node.rb', line 7987 def format(q) FlowControlFormatter.new("next", self).format(q) end |