Class: SyntaxTree::ArgBlock
- Inherits:
-
Object
- Object
- SyntaxTree::ArgBlock
- Defined in:
- lib/syntax_tree.rb
Overview
ArgBlock represents using a block operator on an expression.
method(&expression)
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- untyped
-
the expression being turned into a block.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ ArgBlock
constructor
A new instance of ArgBlock.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ ArgBlock
Returns a new instance of ArgBlock.
1185 1186 1187 1188 1189 |
# File 'lib/syntax_tree.rb', line 1185 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1183 1184 1185 |
# File 'lib/syntax_tree.rb', line 1183 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1180 1181 1182 |
# File 'lib/syntax_tree.rb', line 1180 def location @location end |
#value ⇒ Object (readonly)
- untyped
-
the expression being turned into a block
1177 1178 1179 |
# File 'lib/syntax_tree.rb', line 1177 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1191 1192 1193 |
# File 'lib/syntax_tree.rb', line 1191 def child_nodes [value] end |
#format(q) ⇒ Object
1195 1196 1197 1198 |
# File 'lib/syntax_tree.rb', line 1195 def format(q) q.text("&") q.format(value) end |
#pretty_print(q) ⇒ Object
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 |
# File 'lib/syntax_tree.rb', line 1200 def pretty_print(q) q.group(2, "(", ")") do q.text("arg_block") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1211 1212 1213 1214 1215 |
# File 'lib/syntax_tree.rb', line 1211 def to_json(*opts) { type: :arg_block, value: value, loc: location, cmts: comments }.to_json( *opts ) end |