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
-
#block ⇒ Object
readonly
- BlockNode
-
the block being sent with the method call.
-
#call ⇒ Object
readonly
- ARef | CallNode | Command | CommandCall | Super | ZSuper
-
the method call.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid
Constructor Details
#initialize(call:, block:, location:) ⇒ MethodAddBlock
Returns a new instance of MethodAddBlock.
7573
7574
7575
7576
7577
7578
|
# File 'lib/syntax_tree/node.rb', line 7573
def initialize(call:, block:, location:)
@call = call
@block = block
@location = location
@comments = []
end
|
Instance Attribute Details
#block ⇒ Object
- BlockNode
-
the block being sent with the method call
7568
7569
7570
|
# File 'lib/syntax_tree/node.rb', line 7568
def block
@block
end
|
#call ⇒ Object
- ARef | CallNode | Command | CommandCall | Super | ZSuper
-
the method call
7565
7566
7567
|
# File 'lib/syntax_tree/node.rb', line 7565
def call
@call
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7571
7572
7573
|
# File 'lib/syntax_tree/node.rb', line 7571
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
7622
7623
7624
7625
|
# File 'lib/syntax_tree/node.rb', line 7622
def ===(other)
other.is_a?(MethodAddBlock) && call === other.call &&
block === other.block
end
|
#accept(visitor) ⇒ Object
7580
7581
7582
|
# File 'lib/syntax_tree/node.rb', line 7580
def accept(visitor)
visitor.visit_method_add_block(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7584
7585
7586
|
# File 'lib/syntax_tree/node.rb', line 7584
def child_nodes
[call, block]
end
|
#copy(call: nil, block: nil, location: nil) ⇒ Object
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
|
# File 'lib/syntax_tree/node.rb', line 7588
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
7602
7603
7604
|
# File 'lib/syntax_tree/node.rb', line 7602
def deconstruct_keys(_keys)
{ call: call, block: block, location: location, comments: }
end
|
#format_contents(q) ⇒ Object
7627
7628
7629
7630
|
# File 'lib/syntax_tree/node.rb', line 7627
def format_contents(q)
q.format(call)
q.format(block)
end
|