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.
7906 7907 7908 7909 7910 |
# File 'lib/syntax_tree.rb', line 7906 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
7904 7905 7906 |
# File 'lib/syntax_tree.rb', line 7904 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7901 7902 7903 |
# File 'lib/syntax_tree.rb', line 7901 def location @location end |
#value ⇒ Object (readonly)
- String
-
the left parenthesis
7898 7899 7900 |
# File 'lib/syntax_tree.rb', line 7898 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7912 7913 7914 |
# File 'lib/syntax_tree.rb', line 7912 def child_nodes [] end |
#format(q) ⇒ Object
7916 7917 7918 |
# File 'lib/syntax_tree.rb', line 7916 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 |
# File 'lib/syntax_tree.rb', line 7920 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
7931 7932 7933 7934 7935 |
# File 'lib/syntax_tree.rb', line 7931 def to_json(*opts) { type: :lparen, value: value, loc: location, cmts: comments }.to_json( *opts ) end |