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.
2656 2657 2658 2659 2660 |
# File 'lib/syntax_tree/node.rb', line 2656 def initialize(arguments:, location:) @arguments = arguments @location = location @comments = [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments being sent to the keyword
2651 2652 2653 |
# File 'lib/syntax_tree/node.rb', line 2651 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2654 2655 2656 |
# File 'lib/syntax_tree/node.rb', line 2654 def comments @comments end |
Instance Method Details
#===(other) ⇒ Object
2691 2692 2693 |
# File 'lib/syntax_tree/node.rb', line 2691 def ===(other) other.is_a?(Break) && arguments === other.arguments end |
#accept(visitor) ⇒ Object
2662 2663 2664 |
# File 'lib/syntax_tree/node.rb', line 2662 def accept(visitor) visitor.visit_break(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2666 2667 2668 |
# File 'lib/syntax_tree/node.rb', line 2666 def child_nodes [arguments] end |
#copy(arguments: nil, location: nil) ⇒ Object
2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 |
# File 'lib/syntax_tree/node.rb', line 2670 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
2683 2684 2685 |
# File 'lib/syntax_tree/node.rb', line 2683 def deconstruct_keys(_keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2687 2688 2689 |
# File 'lib/syntax_tree/node.rb', line 2687 def format(q) FlowControlFormatter.new("break", self).format(q) end |