Class: SyntaxTree::LBrace
- Inherits:
-
Object
- Object
- SyntaxTree::LBrace
- Defined in:
- lib/syntax_tree.rb
Overview
LBrace represents the use of a left brace, i.e., {.
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
- String
-
the left brace.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ LBrace
constructor
A new instance of LBrace.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ LBrace
Returns a new instance of LBrace.
7871 7872 7873 7874 7875 |
# File 'lib/syntax_tree.rb', line 7871 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
7869 7870 7871 |
# File 'lib/syntax_tree.rb', line 7869 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7866 7867 7868 |
# File 'lib/syntax_tree.rb', line 7866 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left brace
7863 7864 7865 |
# File 'lib/syntax_tree.rb', line 7863 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7877 7878 7879 |
# File 'lib/syntax_tree.rb', line 7877 def child_nodes [] end |
#format(q) ⇒ Object
7881 7882 7883 |
# File 'lib/syntax_tree.rb', line 7881 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 |
# File 'lib/syntax_tree.rb', line 7885 def pretty_print(q) q.group(2, "(", ")") do q.text("lbrace") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7896 7897 7898 7899 7900 |
# File 'lib/syntax_tree.rb', line 7896 def to_json(*opts) { type: :lbrace, value: value, loc: location, cmts: comments }.to_json( *opts ) end |