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.
-
#location ⇒ Object
readonly
- Location
-
the location of this node.
-
#value ⇒ Object
readonly
- String
-
the left bracket.
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.
6990 6991 6992 6993 6994 |
# File 'lib/syntax_tree/node.rb', line 6990 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
6988 6989 6990 |
# File 'lib/syntax_tree/node.rb', line 6988 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
6985 6986 6987 |
# File 'lib/syntax_tree/node.rb', line 6985 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left bracket
6982 6983 6984 |
# File 'lib/syntax_tree/node.rb', line 6982 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
6996 6997 6998 |
# File 'lib/syntax_tree/node.rb', line 6996 def child_nodes [] end |
#deconstruct_keys(keys) ⇒ Object
7002 7003 7004 |
# File 'lib/syntax_tree/node.rb', line 7002 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
7006 7007 7008 |
# File 'lib/syntax_tree/node.rb', line 7006 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 |
# File 'lib/syntax_tree/node.rb', line 7010 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
7021 7022 7023 7024 7025 |
# File 'lib/syntax_tree/node.rb', line 7021 def to_json(*opts) { type: :lbracket, value: value, loc: location, cmts: comments }.to_json( *opts ) end |