Class: SyntaxTree::LBracket
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.
-
#value ⇒ Object
readonly
- String
-
the left bracket.
Attributes inherited from Node
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ 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.
6747 6748 6749 6750 6751 |
# File 'lib/syntax_tree/node.rb', line 6747 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
6745 6746 6747 |
# File 'lib/syntax_tree/node.rb', line 6745 def comments @comments end |
#value ⇒ Object (readonly)
- String
-
the left bracket
6742 6743 6744 |
# File 'lib/syntax_tree/node.rb', line 6742 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
6753 6754 6755 |
# File 'lib/syntax_tree/node.rb', line 6753 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
6759 6760 6761 |
# File 'lib/syntax_tree/node.rb', line 6759 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
6763 6764 6765 |
# File 'lib/syntax_tree/node.rb', line 6763 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 |
# File 'lib/syntax_tree/node.rb', line 6767 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
6778 6779 6780 6781 6782 |
# File 'lib/syntax_tree/node.rb', line 6778 def to_json(*opts) { type: :lbracket, value: value, loc: location, cmts: comments }.to_json( *opts ) end |