Class: SyntaxTree::MethodAddBlock
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::MethodAddBlock
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
MethodAddBlock represents a method call with a block argument.
method {}
Instance Attribute Summary collapse
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(call:, block:, location:) ⇒ MethodAddBlock
Returns a new instance of MethodAddBlock.
7472
7473
7474
7475
7476
7477
|
# File 'lib/syntax_tree/node.rb', line 7472
def initialize(call:, block:, location:)
@call = call
@block = block
@location = location
@comments = []
end
|
Instance Attribute Details
#block ⇒ Object
- Block
-
the block being sent with the method call
7467
7468
7469
|
# File 'lib/syntax_tree/node.rb', line 7467
def block
@block
end
|
#call ⇒ Object
- Call | Command | CommandCall
-
the method call
7464
7465
7466
|
# File 'lib/syntax_tree/node.rb', line 7464
def call
@call
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7470
7471
7472
|
# File 'lib/syntax_tree/node.rb', line 7470
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
7521
7522
7523
7524
|
# File 'lib/syntax_tree/node.rb', line 7521
def ===(other)
other.is_a?(MethodAddBlock) && call === other.call &&
block === other.block
end
|
#accept(visitor) ⇒ Object
7479
7480
7481
|
# File 'lib/syntax_tree/node.rb', line 7479
def accept(visitor)
visitor.visit_method_add_block(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7483
7484
7485
|
# File 'lib/syntax_tree/node.rb', line 7483
def child_nodes
[call, block]
end
|
#copy(call: nil, block: nil, location: nil) ⇒ Object
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
|
# File 'lib/syntax_tree/node.rb', line 7487
def copy(call: nil, block: nil, location: nil)
node =
MethodAddBlock.new(
call: call || self.call,
block: block || self.block,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
7501
7502
7503
|
# File 'lib/syntax_tree/node.rb', line 7501
def deconstruct_keys(_keys)
{ call: call, block: block, location: location, comments: }
end
|
#format_contents(q) ⇒ Object
7526
7527
7528
7529
|
# File 'lib/syntax_tree/node.rb', line 7526
def format_contents(q)
q.format(call)
q.format(block)
end
|