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.
3987 3988 3989 3990 3991 |
# File 'lib/syntax_tree.rb', line 3987 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
3985 3986 3987 |
# File 'lib/syntax_tree.rb', line 3985 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
3982 3983 3984 |
# File 'lib/syntax_tree.rb', line 3982 def location @location end |
#value ⇒ Object (readonly)
- String
-
the name of the class variable
3979 3980 3981 |
# File 'lib/syntax_tree.rb', line 3979 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
3993 3994 3995 |
# File 'lib/syntax_tree.rb', line 3993 def child_nodes [] end |
#format(q) ⇒ Object
3997 3998 3999 |
# File 'lib/syntax_tree.rb', line 3997 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 |
# File 'lib/syntax_tree.rb', line 4001 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
4012 4013 4014 4015 4016 |
# File 'lib/syntax_tree.rb', line 4012 def to_json(*opts) { type: :cvar, value: value, loc: location, cmts: comments }.to_json( *opts ) end |