Class: SyntaxTree::AssocSplat

Inherits:
Node
  • Object
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

#pretty_print, #to_json

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

#commentsObject (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

#valueObject (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_nodesObject 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