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.
4249 4250 4251 4252 4253 |
# File 'lib/syntax_tree.rb', line 4249 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
4247 4248 4249 |
# File 'lib/syntax_tree.rb', line 4247 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
4244 4245 4246 |
# File 'lib/syntax_tree.rb', line 4244 def location @location end |
#value ⇒ Object (readonly)
- String
-
the name of the class variable
4241 4242 4243 |
# File 'lib/syntax_tree.rb', line 4241 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
4255 4256 4257 |
# File 'lib/syntax_tree.rb', line 4255 def child_nodes [] end |
#format(q) ⇒ Object
4259 4260 4261 |
# File 'lib/syntax_tree.rb', line 4259 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 |
# File 'lib/syntax_tree.rb', line 4263 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
4274 4275 4276 4277 4278 |
# File 'lib/syntax_tree.rb', line 4274 def to_json(*opts) { type: :cvar, value: value, loc: location, cmts: comments }.to_json( *opts ) end |