Class: SyntaxTree::AssocSplat
- Inherits:
-
Node
- Object
- Node
- SyntaxTree::AssocSplat
show all
- Defined in:
- lib/syntax_tree/node.rb
Overview
AssocSplat represents double-splatting a value into a hash (either a hash literal or a bare hash in a method call).
{ **pairs }
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(value:, location:) ⇒ AssocSplat
Returns a new instance of AssocSplat.
1613
1614
1615
1616
1617
|
# File 'lib/syntax_tree/node.rb', line 1613
def initialize(value:, location:)
@value = value
@location = location
= []
end
|
Instance Attribute Details
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1611
1612
1613
|
# File 'lib/syntax_tree/node.rb', line 1611
def
end
|
#value ⇒ Object
- untyped
-
the expression that is being splatted
1608
1609
1610
|
# File 'lib/syntax_tree/node.rb', line 1608
def value
@value
end
|
Instance Method Details
#===(other) ⇒ Object
1649
1650
1651
|
# File 'lib/syntax_tree/node.rb', line 1649
def ===(other)
other.is_a?(AssocSplat) && value === other.value
end
|
#accept(visitor) ⇒ Object
1619
1620
1621
|
# File 'lib/syntax_tree/node.rb', line 1619
def accept(visitor)
visitor.visit_assoc_splat(self)
end
|
#child_nodes ⇒ Object
Also known as:
deconstruct
1623
1624
1625
|
# File 'lib/syntax_tree/node.rb', line 1623
def child_nodes
[value]
end
|
#copy(value: nil, location: nil) ⇒ Object
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
|
# File 'lib/syntax_tree/node.rb', line 1627
def copy(value: nil, location: nil)
node =
AssocSplat.new(
value: value || self.value,
location: location || self.location
)
node..concat(.map(&:copy))
node
end
|
#deconstruct_keys(_keys) ⇒ Object
1640
1641
1642
|
# File 'lib/syntax_tree/node.rb', line 1640
def deconstruct_keys(_keys)
{ value: value, location: location, comments: }
end
|
1644
1645
1646
1647
|
# File 'lib/syntax_tree/node.rb', line 1644
def format(q)
q.text("**")
q.format(value)
end
|