Class: SyntaxTree::LBracket
- Inherits:
-
Object
- Object
- SyntaxTree::LBracket
- Defined in:
- lib/syntax_tree.rb
Overview
LBracket represents the use of a left bracket, 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 bracket.
Instance Method Summary collapse
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ LBracket
constructor
A new instance of LBracket.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ LBracket
Returns a new instance of LBracket.
7854 7855 7856 7857 7858 |
# File 'lib/syntax_tree.rb', line 7854 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
7852 7853 7854 |
# File 'lib/syntax_tree.rb', line 7852 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7849 7850 7851 |
# File 'lib/syntax_tree.rb', line 7849 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left bracket
7846 7847 7848 |
# File 'lib/syntax_tree.rb', line 7846 def value @value end |
Instance Method Details
#format(q) ⇒ Object
7860 7861 7862 |
# File 'lib/syntax_tree.rb', line 7860 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 |
# File 'lib/syntax_tree.rb', line 7864 def pretty_print(q) q.group(2, "(", ")") do q.text("lbracket") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7875 7876 7877 7878 7879 |
# File 'lib/syntax_tree.rb', line 7875 def to_json(*opts) { type: :lbracket, value: value, loc: location, cmts: comments }.to_json( *opts ) end |