Class: SyntaxTree::CVar
- Inherits:
-
Object
- Object
- SyntaxTree::CVar
- Defined in:
- lib/syntax_tree.rb
Overview
CVar represents the use of a class variable.
@@variable
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 name of the class variable.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ CVar
constructor
A new instance of CVar.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ CVar
Returns a new instance of CVar.
4411 4412 4413 4414 4415 |
# File 'lib/syntax_tree.rb', line 4411 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
4409 4410 4411 |
# File 'lib/syntax_tree.rb', line 4409 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
4406 4407 4408 |
# File 'lib/syntax_tree.rb', line 4406 def location @location end |
#value ⇒ Object (readonly)
- String
-
the name of the class variable
4403 4404 4405 |
# File 'lib/syntax_tree.rb', line 4403 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
4417 4418 4419 |
# File 'lib/syntax_tree.rb', line 4417 def child_nodes [] end |
#format(q) ⇒ Object
4421 4422 4423 |
# File 'lib/syntax_tree.rb', line 4421 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 |
# File 'lib/syntax_tree.rb', line 4425 def pretty_print(q) q.group(2, "(", ")") do q.text("cvar") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
4436 4437 4438 4439 4440 |
# File 'lib/syntax_tree.rb', line 4436 def to_json(*opts) { type: :cvar, value: value, loc: location, cmts: comments }.to_json( *opts ) end |