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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(arguments:, location:, comments: []) ⇒ Break
constructor
A new instance of Break.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(arguments:, location:, comments: []) ⇒ Break
Returns a new instance of Break.
2645 2646 2647 2648 2649 |
# File 'lib/syntax_tree/node.rb', line 2645 def initialize(arguments:, location:, comments: []) @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments being sent to the keyword
2637 2638 2639 |
# File 'lib/syntax_tree/node.rb', line 2637 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2643 2644 2645 |
# File 'lib/syntax_tree/node.rb', line 2643 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
2640 2641 2642 |
# File 'lib/syntax_tree/node.rb', line 2640 def location @location end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
2651 2652 2653 |
# File 'lib/syntax_tree/node.rb', line 2651 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
2657 2658 2659 |
# File 'lib/syntax_tree/node.rb', line 2657 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2661 2662 2663 |
# File 'lib/syntax_tree/node.rb', line 2661 def format(q) FlowControlFormatter.new("break", self).format(q) end |
#pretty_print(q) ⇒ Object
2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 |
# File 'lib/syntax_tree/node.rb', line 2665 def pretty_print(q) q.group(2, "(", ")") do q.text("break") q.breakable q.pp(arguments) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
2676 2677 2678 2679 2680 |
# File 'lib/syntax_tree/node.rb', line 2676 def to_json(*opts) { type: :break, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |