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.
-
#value ⇒ Object
readonly
[Const | Ident] the name of the method.
Attributes inherited from Node
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.
4899 4900 4901 4902 4903 4904 |
# File 'lib/syntax_tree/node.rb', line 4899 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
4894 4895 4896 |
# File 'lib/syntax_tree/node.rb', line 4894 def arguments @arguments end |
#comments ⇒ Object (readonly)
[Array[ Comment | EmbDoc ]] the comments attached to this node
4897 4898 4899 |
# File 'lib/syntax_tree/node.rb', line 4897 def comments @comments end |
#value ⇒ Object (readonly)
[Const | Ident] the name of the method
4891 4892 4893 |
# File 'lib/syntax_tree/node.rb', line 4891 def value @value end |
Instance Method Details
#child_nodes ⇒ Object Also known as: deconstruct
4906 4907 4908 |
# File 'lib/syntax_tree/node.rb', line 4906 def child_nodes [value, arguments] end |
#deconstruct_keys(keys) ⇒ Object
4912 4913 4914 4915 4916 4917 4918 4919 |
# File 'lib/syntax_tree/node.rb', line 4912 def deconstruct_keys(keys) { value: value, arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
4921 4922 4923 4924 |
# File 'lib/syntax_tree/node.rb', line 4921 def format(q) q.format(value) q.format(arguments) end |
#pretty_print(q) ⇒ Object
4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 |
# File 'lib/syntax_tree/node.rb', line 4926 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
4942 4943 4944 4945 4946 4947 4948 4949 4950 |
# File 'lib/syntax_tree/node.rb', line 4942 def to_json(*opts) { type: :fcall, value: value, args: arguments, loc: location, cmts: comments }.to_json(*opts) end |