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
- #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.
2564 2565 2566 2567 2568 |
# File 'lib/syntax_tree/node.rb', line 2564 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
2559 2560 2561 |
# File 'lib/syntax_tree/node.rb', line 2559 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2562 2563 2564 |
# File 'lib/syntax_tree/node.rb', line 2562 def comments @comments end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
2570 2571 2572 |
# File 'lib/syntax_tree/node.rb', line 2570 def child_nodes [arguments] end |
#deconstruct_keys(keys) ⇒ Object
2576 2577 2578 |
# File 'lib/syntax_tree/node.rb', line 2576 def deconstruct_keys(keys) { arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2580 2581 2582 |
# File 'lib/syntax_tree/node.rb', line 2580 def format(q) FlowControlFormatter.new("break", self).format(q) end |
#pretty_print(q) ⇒ Object
2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 |
# File 'lib/syntax_tree/node.rb', line 2584 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
2595 2596 2597 2598 2599 |
# File 'lib/syntax_tree/node.rb', line 2595 def to_json(*opts) { type: :break, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |