Class: SyntaxTree::LParen
- Inherits:
-
Object
- Object
- SyntaxTree::LParen
- Defined in:
- lib/syntax_tree.rb
Overview
LParen represents the use of a left parenthesis, 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 parenthesis.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ LParen
constructor
A new instance of LParen.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ LParen
Returns a new instance of LParen.
8115 8116 8117 8118 8119 |
# File 'lib/syntax_tree.rb', line 8115 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
8113 8114 8115 |
# File 'lib/syntax_tree.rb', line 8113 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
8110 8111 8112 |
# File 'lib/syntax_tree.rb', line 8110 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left parenthesis
8107 8108 8109 |
# File 'lib/syntax_tree.rb', line 8107 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
8121 8122 8123 |
# File 'lib/syntax_tree.rb', line 8121 def child_nodes [] end |
#format(q) ⇒ Object
8125 8126 8127 |
# File 'lib/syntax_tree.rb', line 8125 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 |
# File 'lib/syntax_tree.rb', line 8129 def pretty_print(q) q.group(2, "(", ")") do q.text("lparen") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
8140 8141 8142 8143 8144 |
# File 'lib/syntax_tree.rb', line 8140 def to_json(*opts) { type: :lparen, value: value, loc: location, cmts: comments }.to_json( *opts ) end |