Class: SyntaxTree::AssocSplat
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
-
#comments ⇒ Object
readonly
[Array[ Comment | EmbDoc ]] the comments attached to this node.
-
#value ⇒ Object
readonly
[untyped] the expression that is being splatted.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ AssocSplat
constructor
A new instance of AssocSplat.
Methods inherited from Node
Constructor Details
#initialize(value:, location:, comments: []) ⇒ AssocSplat
Returns a new instance of AssocSplat.
1182 1183 1184 1185 1186 |
# File 'lib/syntax_tree/node.rb', line 1182 def initialize(value:, location:, comments: []) @value = value @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
[Array[ Comment | EmbDoc ]] the comments attached to this node
1180 1181 1182 |
# File 'lib/syntax_tree/node.rb', line 1180 def comments @comments end |
#value ⇒ Object (readonly)
[untyped] the expression that is being splatted
1177 1178 1179 |
# File 'lib/syntax_tree/node.rb', line 1177 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
1188 1189 1190 |
# File 'lib/syntax_tree/node.rb', line 1188 def accept(visitor) visitor.visit_assoc_splat(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1192 1193 1194 |
# File 'lib/syntax_tree/node.rb', line 1192 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
1198 1199 1200 |
# File 'lib/syntax_tree/node.rb', line 1198 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1202 1203 1204 1205 |
# File 'lib/syntax_tree/node.rb', line 1202 def format(q) q.text("**") q.format(value) end |