Class: SyntaxTree::Break
- Inherits:
-
Object
- Object
- SyntaxTree::Break
- Defined in:
- lib/syntax_tree.rb
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
- #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.
3094 3095 3096 3097 3098 |
# File 'lib/syntax_tree.rb', line 3094 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
3086 3087 3088 |
# File 'lib/syntax_tree.rb', line 3086 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
3092 3093 3094 |
# File 'lib/syntax_tree.rb', line 3092 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
3089 3090 3091 |
# File 'lib/syntax_tree.rb', line 3089 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
3100 3101 3102 |
# File 'lib/syntax_tree.rb', line 3100 def child_nodes [arguments] end |
#format(q) ⇒ Object
3104 3105 3106 |
# File 'lib/syntax_tree.rb', line 3104 def format(q) FlowControlFormatter.new("break", self).format(q) end |
#pretty_print(q) ⇒ Object
3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 |
# File 'lib/syntax_tree.rb', line 3108 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
3119 3120 3121 3122 3123 |
# File 'lib/syntax_tree.rb', line 3119 def to_json(*opts) { type: :break, args: arguments, loc: location, cmts: comments }.to_json( *opts ) end |