Class: SyntaxTree::VCall
Overview
VCall represent any plain named object with Ruby that could be either a local variable or a method call.
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
- Ident
-
the value of this expression.
Instance Method Summary collapse
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ VCall
constructor
A new instance of VCall.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ VCall
Returns a new instance of VCall.
11209 11210 11211 11212 11213 |
# File 'lib/syntax_tree/node.rb', line 11209 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
11207 11208 11209 |
# File 'lib/syntax_tree/node.rb', line 11207 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
11204 11205 11206 |
# File 'lib/syntax_tree/node.rb', line 11204 def location @location end |
#value ⇒ Object (readonly)
- Ident
-
the value of this expression
11201 11202 11203 |
# File 'lib/syntax_tree/node.rb', line 11201 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
11215 11216 11217 |
# File 'lib/syntax_tree/node.rb', line 11215 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
11221 11222 11223 |
# File 'lib/syntax_tree/node.rb', line 11221 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
11225 11226 11227 |
# File 'lib/syntax_tree/node.rb', line 11225 def format(q) q.format(value) end |
#pretty_print(q) ⇒ Object
11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 |
# File 'lib/syntax_tree/node.rb', line 11229 def pretty_print(q) q.group(2, "(", ")") do q.text("vcall") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
11240 11241 11242 11243 11244 |
# File 'lib/syntax_tree/node.rb', line 11240 def to_json(*opts) { type: :vcall, value: value, loc: location, cmts: comments }.to_json( *opts ) end |