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.
-
#value ⇒ Object
readonly
- Ident
-
the value of this expression.
Attributes inherited from Node
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.
10768 10769 10770 10771 10772 |
# File 'lib/syntax_tree/node.rb', line 10768 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
10766 10767 10768 |
# File 'lib/syntax_tree/node.rb', line 10766 def comments @comments end |
#value ⇒ Object (readonly)
- Ident
-
the value of this expression
10763 10764 10765 |
# File 'lib/syntax_tree/node.rb', line 10763 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
10774 10775 10776 |
# File 'lib/syntax_tree/node.rb', line 10774 def child_nodes [value] end |
#deconstruct_keys(keys) ⇒ Object
10780 10781 10782 |
# File 'lib/syntax_tree/node.rb', line 10780 def deconstruct_keys(keys) { value: value, location: location, comments: comments } end |
#format(q) ⇒ Object
10784 10785 10786 |
# File 'lib/syntax_tree/node.rb', line 10784 def format(q) q.format(value) end |
#pretty_print(q) ⇒ Object
10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 |
# File 'lib/syntax_tree/node.rb', line 10788 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
10799 10800 10801 10802 10803 |
# File 'lib/syntax_tree/node.rb', line 10799 def to_json(*opts) { type: :vcall, value: value, loc: location, cmts: comments }.to_json( *opts ) end |