Class: SyntaxTree::IVar
- Inherits:
-
Object
- Object
- SyntaxTree::IVar
- Defined in:
- lib/syntax_tree.rb
Overview
IVar represents an instance variable literal.
@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 instance variable.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ IVar
constructor
A new instance of IVar.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ IVar
Returns a new instance of IVar.
7035 7036 7037 7038 7039 |
# File 'lib/syntax_tree.rb', line 7035 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
7033 7034 7035 |
# File 'lib/syntax_tree.rb', line 7033 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
7030 7031 7032 |
# File 'lib/syntax_tree.rb', line 7030 def location @location end |
#value ⇒ Object (readonly)
- String
-
the name of the instance variable
7027 7028 7029 |
# File 'lib/syntax_tree.rb', line 7027 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
7041 7042 7043 |
# File 'lib/syntax_tree.rb', line 7041 def child_nodes [] end |
#format(q) ⇒ Object
7045 7046 7047 |
# File 'lib/syntax_tree.rb', line 7045 def format(q) q.text(value) end |
#pretty_print(q) ⇒ Object
7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 |
# File 'lib/syntax_tree.rb', line 7049 def pretty_print(q) q.group(2, "(", ")") do q.text("ivar") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
7060 7061 7062 7063 7064 |
# File 'lib/syntax_tree.rb', line 7060 def to_json(*opts) { type: :ivar, value: value, loc: location, cmts: comments }.to_json( *opts ) end |