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.
1938 1939 1940 1941 1942 |
# File 'lib/syntax_tree.rb', line 1938 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
1936 1937 1938 |
# File 'lib/syntax_tree.rb', line 1936 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1933 1934 1935 |
# File 'lib/syntax_tree.rb', line 1933 def location @location end |
#value ⇒ Object (readonly)
- untyped
-
the expression that is being splatted
1930 1931 1932 |
# File 'lib/syntax_tree.rb', line 1930 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
1944 1945 1946 |
# File 'lib/syntax_tree.rb', line 1944 def child_nodes [value] end |
#format(q) ⇒ Object
1948 1949 1950 1951 |
# File 'lib/syntax_tree.rb', line 1948 def format(q) q.text("**") q.format(value) end |
#pretty_print(q) ⇒ Object
1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 |
# File 'lib/syntax_tree.rb', line 1953 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
1964 1965 1966 1967 1968 1969 1970 1971 |
# File 'lib/syntax_tree.rb', line 1964 def to_json(*opts) { type: :assoc_splat, value: value, loc: location, cmts: comments }.to_json(*opts) end |