Class: SyntaxTree::AssocSplat
- Inherits:
-
Object
- Object
- SyntaxTree::AssocSplat
- Defined in:
- lib/syntax_tree.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
-
#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
- #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.
1828 1829 1830 1831 1832 |
# File 'lib/syntax_tree.rb', line 1828 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
1826 1827 1828 |
# File 'lib/syntax_tree.rb', line 1826 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1823 1824 1825 |
# File 'lib/syntax_tree.rb', line 1823 def location @location end |
#value ⇒ Object (readonly)
- untyped
-
the expression that is being splatted
1820 1821 1822 |
# File 'lib/syntax_tree.rb', line 1820 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1834 1835 1836 |
# File 'lib/syntax_tree.rb', line 1834 def child_nodes [value] end |
#format(q) ⇒ Object
1838 1839 1840 1841 |
# File 'lib/syntax_tree.rb', line 1838 def format(q) q.text("**") q.format(value) end |
#pretty_print(q) ⇒ Object
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 |
# File 'lib/syntax_tree.rb', line 1843 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
1854 1855 1856 1857 1858 1859 1860 1861 |
# File 'lib/syntax_tree.rb', line 1854 def to_json(*opts) { type: :assoc_splat, value: value, loc: location, cmts: comments }.to_json(*opts) end |