Class: SyntaxTree::FCall
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
-
#arguments ⇒ Object
readonly
- nil | ArgParen | Args
-
the arguments to the method call.
-
#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 (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(value:, arguments:, location:, comments: []) ⇒ FCall
constructor
A new instance of FCall.
- #pretty_print(q) ⇒ Object
- #to_json(*opts) ⇒ Object
Constructor Details
#initialize(value:, arguments:, location:, comments: []) ⇒ FCall
Returns a new instance of FCall.
5070 5071 5072 5073 5074 5075 |
# File 'lib/syntax_tree/node.rb', line 5070 def initialize(value:, arguments:, location:, comments: []) @value = value @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- nil | ArgParen | Args
-
the arguments to the method call
5062 5063 5064 |
# File 'lib/syntax_tree/node.rb', line 5062 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
5068 5069 5070 |
# File 'lib/syntax_tree/node.rb', line 5068 def comments @comments end |
#location ⇒ Object (readonly)
- Location
-
the location of this node
5065 5066 5067 |
# File 'lib/syntax_tree/node.rb', line 5065 def location @location end |
#value ⇒ Object (readonly)
- Const | Ident
-
the name of the method
5059 5060 5061 |
# File 'lib/syntax_tree/node.rb', line 5059 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
5077 5078 5079 |
# File 'lib/syntax_tree/node.rb', line 5077 def child_nodes [value, arguments] end |
#deconstruct_keys(keys) ⇒ Object
5083 5084 5085 5086 5087 5088 5089 5090 |
# File 'lib/syntax_tree/node.rb', line 5083 def deconstruct_keys(keys) { value: value, arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
5092 5093 5094 5095 |
# File 'lib/syntax_tree/node.rb', line 5092 def format(q) q.format(value) q.format(arguments) end |
#pretty_print(q) ⇒ Object
5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 |
# File 'lib/syntax_tree/node.rb', line 5097 def pretty_print(q) q.group(2, "(", ")") do q.text("fcall") q.breakable q.pp(value) if arguments q.breakable q.pp(arguments) end q.pp(Comment::List.new(comments)) end end |
#to_json(*opts) ⇒ Object
5113 5114 5115 5116 5117 5118 5119 5120 5121 |
# File 'lib/syntax_tree/node.rb', line 5113 def to_json(*opts) { type: :fcall, value: value, args: arguments, loc: location, cmts: comments }.to_json(*opts) end |