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.
7422 7423 7424 7425 7426 |
# File 'lib/syntax_tree.rb', line 7422 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
7420 7421 7422 |
# File 'lib/syntax_tree.rb', line 7420 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7417 7418 7419 |
# File 'lib/syntax_tree.rb', line 7417 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left brace
7414 7415 7416 |
# File 'lib/syntax_tree.rb', line 7414 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7428 7429 7430 |
# File 'lib/syntax_tree.rb', line 7428 def child_nodes [] end |
#format(q) ⇒ Object
7432 7433 7434 |
# File 'lib/syntax_tree.rb', line 7432 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 |
# File 'lib/syntax_tree.rb', line 7436 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
7447 7448 7449 7450 7451 |
# File 'lib/syntax_tree.rb', line 7447 def to_json(*opts) { type: :lbrace, value: value, loc: location, cmts: comments }.to_json( *opts ) end |