Class: SyntaxTree::FCall
- Inherits:
-
Object
- Object
- SyntaxTree::FCall
- Defined in:
- lib/syntax_tree.rb
Overview
FCall represents the piece of a method call that comes before any arguments (i.e., just the name of the method). It is used in places where the parser is sure that it is a method call and not potentially a local variable.
method(argument)
In the above example, it’s referring to the method segment.
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
- Const | Ident
-
the name of the method.
Instance Method Summary collapse
- #child_nodes ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, location:, comments: []) ⇒ FCall
constructor
A new instance of FCall.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, location:, comments: []) ⇒ FCall
Returns a new instance of FCall.
5489 5490 5491 5492 5493 |
# File 'lib/syntax_tree.rb', line 5489 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
5487 5488 5489 |
# File 'lib/syntax_tree.rb', line 5487 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
5484 5485 5486 |
# File 'lib/syntax_tree.rb', line 5484 def location @location end |
#value ⇒ Object (readonly)
- Const | Ident
-
the name of the method
5481 5482 5483 |
# File 'lib/syntax_tree.rb', line 5481 def value @value end |
Instance Method Details
#child_nodes ⇒ Object
5495 5496 5497 |
# File 'lib/syntax_tree.rb', line 5495 def child_nodes [value] end |
#format(q) ⇒ Object
5499 5500 5501 |
# File 'lib/syntax_tree.rb', line 5499 def format(q) q.format(value) end |
#pretty_print(q) ⇒ Object
5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 |
# File 'lib/syntax_tree.rb', line 5503 def pretty_print(q) q.group(2, "(", ")") do q.text("fcall") q.breakable q.pp(value) q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
5514 5515 5516 5517 5518 |
# File 'lib/syntax_tree.rb', line 5514 def to_json(*opts) { type: :fcall, value: value, loc: location, cmts: comments }.to_json( *opts ) end |