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, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(arguments:, location:) ⇒ Break
Returns a new instance of Break.
2641 2642 2643 2644 2645 |
# File 'lib/syntax_tree/node.rb', line 2641 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments being sent to the keyword
2636 2637 2638 |
# File 'lib/syntax_tree/node.rb', line 2636 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2639 2640 2641 |
# File 'lib/syntax_tree/node.rb', line 2639 def comments @comments end |
Instance Method Details
#===(other) ⇒ Object
2676 2677 2678 |
# File 'lib/syntax_tree/node.rb', line 2676 def ===(other) other.is_a?(Break) && arguments === other.arguments end |
#accept(visitor) ⇒ Object
2647 2648 2649 |
# File 'lib/syntax_tree/node.rb', line 2647 def accept(visitor) visitor.visit_break(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2651 2652 2653 |
# File 'lib/syntax_tree/node.rb', line 2651 def child_nodes [arguments] end |
#copy(arguments: nil, location: nil) ⇒ Object
2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 |
# File 'lib/syntax_tree/node.rb', line 2655 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
2668 2669 2670 |
# File 'lib/syntax_tree/node.rb', line 2668 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2672 2673 2674 |
# File 'lib/syntax_tree/node.rb', line 2672 def format(q) FlowControlFormatter.new("break", self).format(q) end |