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.
7460
7461
7462
7463
7464
7465
|
# File 'lib/syntax_tree/node.rb', line 7460
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
7455
7456
7457
|
# File 'lib/syntax_tree/node.rb', line 7455
def block
@block
end
|
#call ⇒ Object
- Call | Command | CommandCall
-
the method call
7452
7453
7454
|
# File 'lib/syntax_tree/node.rb', line 7452
def call
@call
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7458
7459
7460
|
# File 'lib/syntax_tree/node.rb', line 7458
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
7509
7510
7511
7512
|
# File 'lib/syntax_tree/node.rb', line 7509
def ===(other)
other.is_a?(MethodAddBlock) && call === other.call &&
block === other.block
end
|
#accept(visitor) ⇒ Object
7467
7468
7469
|
# File 'lib/syntax_tree/node.rb', line 7467
def accept(visitor)
visitor.visit_method_add_block(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7471
7472
7473
|
# File 'lib/syntax_tree/node.rb', line 7471
def child_nodes
[call, block]
end
|
#copy(call: nil, block: nil, location: nil) ⇒ Object
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
|
# File 'lib/syntax_tree/node.rb', line 7475
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
7489
7490
7491
|
# File 'lib/syntax_tree/node.rb', line 7489
def deconstruct_keys(_keys)
{ call: call, block: block, location: location, comments: }
end
|
#format_contents(q) ⇒ Object
7514
7515
7516
7517
|
# File 'lib/syntax_tree/node.rb', line 7514
def format_contents(q)
q.format(call)
q.format(block)
end
|