Class: SyntaxTree::Break
Overview
Break represents using the break keyword.
break
It can also optionally accept arguments, as in:
break 1
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- Args
-
the arguments being sent to the 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:) ⇒ Break
constructor
A new instance of Break.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(arguments:, location:) ⇒ Break
Returns a new instance of Break.
2614 2615 2616 2617 2618 |
# File 'lib/syntax_tree/node.rb', line 2614 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments being sent to the keyword
2609 2610 2611 |
# File 'lib/syntax_tree/node.rb', line 2609 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2612 2613 2614 |
# File 'lib/syntax_tree/node.rb', line 2612 def comments @comments end |
Instance Method Details
#===(other) ⇒ Object
2649 2650 2651 |
# File 'lib/syntax_tree/node.rb', line 2649 def ===(other) other.is_a?(Break) && arguments === other.arguments end |
#accept(visitor) ⇒ Object
2620 2621 2622 |
# File 'lib/syntax_tree/node.rb', line 2620 def accept(visitor) visitor.visit_break(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2624 2625 2626 |
# File 'lib/syntax_tree/node.rb', line 2624 def child_nodes [arguments] end |
#copy(arguments: nil, location: nil) ⇒ Object
2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 |
# File 'lib/syntax_tree/node.rb', line 2628 def copy(arguments: nil, location: nil) node = Break.new( arguments: arguments || self.arguments, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end |
#deconstruct_keys(_keys) ⇒ Object
2641 2642 2643 |
# File 'lib/syntax_tree/node.rb', line 2641 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2645 2646 2647 |
# File 'lib/syntax_tree/node.rb', line 2645 def format(q) FlowControlFormatter.new("break", self).format(q) end |