Class: SyntaxTree::VCall
- Inherits:
-
Object
- Object
- SyntaxTree::VCall
- Defined in:
- lib/syntax_tree.rb
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
- #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.
13117 13118 13119 13120 13121 |
# File 'lib/syntax_tree.rb', line 13117 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
13115 13116 13117 |
# File 'lib/syntax_tree.rb', line 13115 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
13112 13113 13114 |
# File 'lib/syntax_tree.rb', line 13112 def location @location end |
#value ⇒ Object (readonly)
- Ident
-
the value of this expression
13109 13110 13111 |
# File 'lib/syntax_tree.rb', line 13109 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
13123 13124 13125 |
# File 'lib/syntax_tree.rb', line 13123 def child_nodes [value] end |
#format(q) ⇒ Object
13127 13128 13129 |
# File 'lib/syntax_tree.rb', line 13127 def format(q) q.format(value) end |
#pretty_print(q) ⇒ Object
13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 |
# File 'lib/syntax_tree.rb', line 13131 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
13142 13143 13144 13145 13146 |
# File 'lib/syntax_tree.rb', line 13142 def to_json(*opts) { type: :vcall, value: value, loc: location, cmts: comments }.to_json( *opts ) end |