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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- untyped
-
the expression that is being splatted.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ AssocSplat
constructor
A new instance of AssocSplat.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ AssocSplat
Returns a new instance of AssocSplat.
1508 1509 1510 1511 1512 |
# File 'lib/syntax_tree/node.rb', line 1508 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
1506 1507 1508 |
# File 'lib/syntax_tree/node.rb', line 1506 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1503 1504 1505 |
# File 'lib/syntax_tree/node.rb', line 1503 def location @location end |
#value ⇒ Object (readonly)
- untyped
-
the expression that is being splatted
1500 1501 1502 |
# File 'lib/syntax_tree/node.rb', line 1500 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
1514 1515 1516 |
# File 'lib/syntax_tree/node.rb', line 1514 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
1520 1521 1522 |
# File 'lib/syntax_tree/node.rb', line 1520 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
1524 1525 1526 1527 |
# File 'lib/syntax_tree/node.rb', line 1524 def format(q) q.text("**") q.format(value) end |
#pretty_print(q) ⇒ Object
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 |
# File 'lib/syntax_tree/node.rb', line 1529 def pretty_print(q) q.group(2, "(", ")") do q.text("assoc_splat") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1540 1541 1542 1543 1544 1545 1546 1547 |
# File 'lib/syntax_tree/node.rb', line 1540 def to_json(*opts) { type: :assoc_splat, value: value, loc: location, cmts: comments }.to_json(*opts) end |