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
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(value:, location:, comments: []) ⇒ AssocSplat
Returns a new instance of AssocSplat.
1299 1300 1301 1302 1303 |
# File 'lib/syntax_tree/node.rb', line 1299 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
1297 1298 1299 |
# File 'lib/syntax_tree/node.rb', line 1297 def comments @comments end |
#value ⇒ Object (readonly)
- untyped
-
the expression that is being splatted
1294 1295 1296 |
# File 'lib/syntax_tree/node.rb', line 1294 def value @value end |
Instance Method Details
#accept(visitor) ⇒ Object
1305 1306 1307 |
# File 'lib/syntax_tree/node.rb', line 1305 def accept(visitor) visitor.visit_assoc_splat(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
1309 1310 1311 |
# File 'lib/syntax_tree/node.rb', line 1309 def child_nodes [value] end |
#deconstruct_keys(_keys) ⇒ Object
1315 1316 1317 |
# File 'lib/syntax_tree/node.rb', line 1315 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1319 1320 1321 1322 |
# File 'lib/syntax_tree/node.rb', line 1319 def format(q) q.text("**") q.format(value) end |