Class: SyntaxTree::ArgBlock
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::ArgBlock
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
ArgBlock represents using a block operator on an expression.
method(&expression)
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#value ⇒ Object
readonly
- nil | untyped
-
the expression being turned into a block.
Attributes inherited from Node
#location
Instance Method Summary
collapse
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:) ⇒ ArgBlock
883
884
885
886
887
|
# File 'lib/syntax_tree/node.rb', line 883
def initialize(value:, location:)
@value = value
@location = location
@comments = []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
881
882
883
|
# File 'lib/syntax_tree/node.rb', line 881
def
@comments
end
|
#value ⇒ Object
- nil | untyped
-
the expression being turned into a block
878
879
880
|
# File 'lib/syntax_tree/node.rb', line 878
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
919
920
921
|
# File 'lib/syntax_tree/node.rb', line 919
def ===(other)
other.is_a?(ArgBlock) && value === other.value
end
|
#accept(visitor) ⇒ Object
889
890
891
|
# File 'lib/syntax_tree/node.rb', line 889
def accept(visitor)
visitor.visit_arg_block(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
893
894
895
|
# File 'lib/syntax_tree/node.rb', line 893
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
897
898
899
900
901
902
903
904
905
906
|
# File 'lib/syntax_tree/node.rb', line 897
def copy(value: nil, location: nil)
node =
ArgBlock.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
910
911
912
|
# File 'lib/syntax_tree/node.rb', line 910
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
914
915
916
917
|
# File 'lib/syntax_tree/node.rb', line 914
def format(q)
q.text("&")
q.format(value) if value
end
|