Class: SyntaxTree::PinnedBegin
Overview
PinnedBegin represents a pinning a nested statement within pattern matching.
case value
in ^(statement)
end
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.
-
#statement ⇒ Object
readonly
- untyped
-
the expression being pinned.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(statement:, location:, comments: []) ⇒ PinnedBegin
constructor
A new instance of PinnedBegin.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(statement:, location:, comments: []) ⇒ PinnedBegin
Returns a new instance of PinnedBegin.
1861 1862 1863 1864 1865 |
# File 'lib/syntax_tree/node.rb', line 1861 def initialize(statement:, location:, comments: []) @statement = statement @location = location @comments = comments end |
Instance Attribute Details
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
1859 1860 1861 |
# File 'lib/syntax_tree/node.rb', line 1859 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
1856 1857 1858 |
# File 'lib/syntax_tree/node.rb', line 1856 def location @location end |
#statement ⇒ Object (readonly)
- untyped
-
the expression being pinned
1853 1854 1855 |
# File 'lib/syntax_tree/node.rb', line 1853 def statement @statement end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
1867 1868 1869 |
# File 'lib/syntax_tree/node.rb', line 1867 def child_nodes [statement] end |
#deconstruct_keys(keys) ⇒ Object
1873 1874 1875 |
# File 'lib/syntax_tree/node.rb', line 1873 def deconstruct_keys(keys) { statement: statement, location: location, comments: comments } end |
#format(q) ⇒ Object
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
# File 'lib/syntax_tree/node.rb', line 1877 def format(q) q.group do q.text("^(") q.nest(1) do q.indent do q.breakable("") q.format(statement) end q.breakable("") q.text(")") end end end |
#pretty_print(q) ⇒ Object
1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 |
# File 'lib/syntax_tree/node.rb', line 1891 def pretty_print(q) q.group(2, "(", ")") do q.text("pinned_begin") q.breakable q.pp(statement) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
1902 1903 1904 1905 1906 1907 1908 1909 |
# File 'lib/syntax_tree/node.rb', line 1902 def to_json(*opts) { type: :pinned_begin, stmt: statement, loc: location, cmts: comments }.to_json(*opts) end |