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.
7589
7590
7591
7592
7593
7594
|
# File 'lib/syntax_tree/node.rb', line 7589
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
7584
7585
7586
|
# File 'lib/syntax_tree/node.rb', line 7584
def block
@block
end
|
#call ⇒ Object
- ARef | CallNode | Command | CommandCall | Super | ZSuper
-
the method call
7581
7582
7583
|
# File 'lib/syntax_tree/node.rb', line 7581
def call
@call
end
|
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
7587
7588
7589
|
# File 'lib/syntax_tree/node.rb', line 7587
def
@comments
end
|
Instance Method Details
#===(other) ⇒ Object
7638
7639
7640
7641
|
# File 'lib/syntax_tree/node.rb', line 7638
def ===(other)
other.is_a?(MethodAddBlock) && call === other.call &&
block === other.block
end
|
#accept(visitor) ⇒ Object
7596
7597
7598
|
# File 'lib/syntax_tree/node.rb', line 7596
def accept(visitor)
visitor.visit_method_add_block(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
7600
7601
7602
|
# File 'lib/syntax_tree/node.rb', line 7600
def child_nodes
[call, block]
end
|
#copy(call: nil, block: nil, location: nil) ⇒ Object
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
|
# File 'lib/syntax_tree/node.rb', line 7604
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
7618
7619
7620
|
# File 'lib/syntax_tree/node.rb', line 7618
def deconstruct_keys(_keys)
{ call: call, block: block, location: location, comments: }
end
|
#format_contents(q) ⇒ Object
7643
7644
7645
7646
|
# File 'lib/syntax_tree/node.rb', line 7643
def format_contents(q)
q.format(call)
q.format(block)
end
|