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.
1230 1231 1232 1233 1234 |
# File 'lib/syntax_tree/node.rb', line 1230 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
1228 1229 1230 |
# File 'lib/syntax_tree/node.rb', line 1228 def comments @comments end |
#value ⇒ Object (readonly)
- untyped
-
the expression that is being splatted
1225 1226 1227 |
# File 'lib/syntax_tree/node.rb', line 1225 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
1236 1237 1238 |
# File 'lib/syntax_tree/node.rb', line 1236 def accept(visitor) visitor.visit_assoc_splat(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1240 1241 1242 |
# File 'lib/syntax_tree/node.rb', line 1240 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
1246 1247 1248 |
# File 'lib/syntax_tree/node.rb', line 1246 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1250 1251 1252 1253 |
# File 'lib/syntax_tree/node.rb', line 1250 def format(q) q.text("**") q.format(value) end |