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.
7798 7799 7800 7801 7802 |
# File 'lib/syntax_tree.rb', line 7798 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
7796 7797 7798 |
# File 'lib/syntax_tree.rb', line 7796 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7793 7794 7795 |
# File 'lib/syntax_tree.rb', line 7793 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left brace
7790 7791 7792 |
# File 'lib/syntax_tree.rb', line 7790 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7804 7805 7806 |
# File 'lib/syntax_tree.rb', line 7804 def child_nodes [] end |
#format(q) ⇒ Object
7808 7809 7810 |
# File 'lib/syntax_tree.rb', line 7808 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 |
# File 'lib/syntax_tree.rb', line 7812 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
7823 7824 7825 7826 7827 |
# File 'lib/syntax_tree.rb', line 7823 def to_json(*opts) { type: :lbrace, value: value, loc: location, cmts: comments }.to_json( *opts ) end |