Class: SyntaxTree::MethodAddBlock
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 (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
7174 7175 7176 7177 7178 7179 |
# File 'lib/syntax_tree/node.rb', line 7174 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
7166 7167 7168 |
# File 'lib/syntax_tree/node.rb', line 7166 def block @block end |
#call ⇒ Object (readonly)
- Call | Command | CommandCall | FCall
-
the method call
7163 7164 7165 |
# File 'lib/syntax_tree/node.rb', line 7163 def call @call end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7172 7173 7174 |
# File 'lib/syntax_tree/node.rb', line 7172 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7169 7170 7171 |
# File 'lib/syntax_tree/node.rb', line 7169 def location @location end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
7181 7182 7183 |
# File 'lib/syntax_tree/node.rb', line 7181 def child_nodes [call, block] end |
#deconstruct_keys(keys) ⇒ Object
7187 7188 7189 |
# File 'lib/syntax_tree/node.rb', line 7187 def deconstruct_keys(keys) { call: call, block: block, location: location, comments: comments } end |
#format(q) ⇒ Object
7191 7192 7193 7194 |
# File 'lib/syntax_tree/node.rb', line 7191 def format(q) q.format(call) q.format(block) end |
#pretty_print(q) ⇒ Object
7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 |
# File 'lib/syntax_tree/node.rb', line 7196 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
7210 7211 7212 7213 7214 7215 7216 7217 7218 |
# File 'lib/syntax_tree/node.rb', line 7210 def to_json(*opts) { type: :method_add_block, call: call, block: block, loc: location, cmts: comments }.to_json(*opts) end |