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.
1172 1173 1174 1175 1176 |
# File 'lib/syntax_tree.rb', line 1172 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
1170 1171 1172 |
# File 'lib/syntax_tree.rb', line 1170 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1167 1168 1169 |
# File 'lib/syntax_tree.rb', line 1167 def location @location end |
#value ⇒ Object (readonly)
- untyped
-
the expression being turned into a block
1164 1165 1166 |
# File 'lib/syntax_tree.rb', line 1164 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1178 1179 1180 |
# File 'lib/syntax_tree.rb', line 1178 def child_nodes [value] end |
#format(q) ⇒ Object
1182 1183 1184 1185 |
# File 'lib/syntax_tree.rb', line 1182 def format(q) q.text("&") q.format(value) end |
#pretty_print(q) ⇒ Object
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 |
# File 'lib/syntax_tree.rb', line 1187 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
1198 1199 1200 1201 1202 |
# File 'lib/syntax_tree.rb', line 1198 def to_json(*opts) { type: :arg_block, value: value, loc: location, cmts: comments }.to_json( *opts ) end |