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
- #child_nodes ⇒ Object
- #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.
7927 7928 7929 7930 7931 |
# File 'lib/syntax_tree.rb', line 7927 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
7925 7926 7927 |
# File 'lib/syntax_tree.rb', line 7925 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7922 7923 7924 |
# File 'lib/syntax_tree.rb', line 7922 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left bracket
7919 7920 7921 |
# File 'lib/syntax_tree.rb', line 7919 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7933 7934 7935 |
# File 'lib/syntax_tree.rb', line 7933 def child_nodes [] end |
#format(q) ⇒ Object
7937 7938 7939 |
# File 'lib/syntax_tree.rb', line 7937 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 |
# File 'lib/syntax_tree.rb', line 7941 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
7952 7953 7954 7955 7956 |
# File 'lib/syntax_tree.rb', line 7952 def to_json(*opts) { type: :lbracket, value: value, loc: location, cmts: comments }.to_json( *opts ) end |