Class: SyntaxTree::Break
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::Break
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
Break represents using the break keyword.
break
It can also optionally accept arguments, as in:
break 1
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(arguments:, location:) ⇒ Break
2614
2615
2616
2617
2618
|
# File 'lib/syntax_tree/node.rb', line 2614
def initialize(arguments:, location:)
@arguments = arguments
@location = location
= []
end
|
Instance Attribute Details
#arguments ⇒ Object
- Args
-
the arguments being sent to the keyword
2609
2610
2611
|
# File 'lib/syntax_tree/node.rb', line 2609
def arguments
@arguments
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2612
2613
2614
|
# File 'lib/syntax_tree/node.rb', line 2612
def
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..concat(.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: }
end
|
2645
2646
2647
|
# File 'lib/syntax_tree/node.rb', line 2645
def format(q)
FlowControlFormatter.new("break", self).format(q)
end
|