Class: SyntaxTree::MethodAddBlock
- Inherits:
-
Object
- Object
- SyntaxTree::MethodAddBlock
- Defined in:
- lib/syntax_tree.rb
Overview
MethodAddBlock represents a method call with a block argument.
method {}
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
- BraceBlock | DoBlock
-
the block being sent with the method call.
-
#call ⇒ Object
readonly
- Call | Command | CommandCall | FCall
-
the method call.
-
#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(call:, block:, location:, comments: []) ⇒ MethodAddBlock
constructor
A new instance of MethodAddBlock.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(call:, block:, location:, comments: []) ⇒ MethodAddBlock
Returns a new instance of MethodAddBlock.
8290 8291 8292 8293 8294 8295 |
# File 'lib/syntax_tree.rb', line 8290 def initialize(call:, block:, location:, comments: []) @call = call @block = block @location = location @comments = comments end |
Instance Attribute Details
#block ⇒ Object (readonly)
- BraceBlock | DoBlock
-
the block being sent with the method call
8282 8283 8284 |
# File 'lib/syntax_tree.rb', line 8282 def block @block end |
#call ⇒ Object (readonly)
- Call | Command | CommandCall | FCall
-
the method call
8279 8280 8281 |
# File 'lib/syntax_tree.rb', line 8279 def call @call end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
8288 8289 8290 |
# File 'lib/syntax_tree.rb', line 8288 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
8285 8286 8287 |
# File 'lib/syntax_tree.rb', line 8285 def location @location end |
Instance Method Details
#child_nodes ⇒ Object
8297 8298 8299 |
# File 'lib/syntax_tree.rb', line 8297 def child_nodes [call, block] end |
#format(q) ⇒ Object
8301 8302 8303 8304 |
# File 'lib/syntax_tree.rb', line 8301 def format(q) q.format(call) q.format(block) end |
#pretty_print(q) ⇒ Object
8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 |
# File 'lib/syntax_tree.rb', line 8306 def pretty_print(q) q.group(2, "(", ")") do q.text("method_add_block") q.breakable q.pp(call) q.breakable q.pp(block) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
8320 8321 8322 8323 8324 8325 8326 8327 8328 |
# File 'lib/syntax_tree.rb', line 8320 def to_json(*opts) { type: :method_add_block, call: call, block: block, loc: location, cmts: comments }.to_json(*opts) end |