Class: SyntaxTree::Command
Overview
Command represents a method call with arguments and no parentheses. Note that Command nodes only happen when there is no explicit receiver for this method.
method argument
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
[Args] the arguments being sent with the message.
-
#comments ⇒ Object
readonly
[Array[ Comment | EmbDoc ]] the comments attached to this node.
-
#message ⇒ Object
readonly
[Const | Ident] the message being sent to the implicit receiver.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(_keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(message:, arguments:, location:, comments: []) ⇒ Command
constructor
A new instance of Command.
Methods inherited from Node
#construct_keys, #pretty_print, #to_json
Constructor Details
#initialize(message:, arguments:, location:, comments: []) ⇒ Command
Returns a new instance of Command.
2940 2941 2942 2943 2944 2945 |
# File 'lib/syntax_tree/node.rb', line 2940 def initialize(message:, arguments:, location:, comments: []) @message = @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
[Args] the arguments being sent with the message
2935 2936 2937 |
# File 'lib/syntax_tree/node.rb', line 2935 def arguments @arguments end |
#comments ⇒ Object (readonly)
[Array[ Comment | EmbDoc ]] the comments attached to this node
2938 2939 2940 |
# File 'lib/syntax_tree/node.rb', line 2938 def comments @comments end |
#message ⇒ Object (readonly)
[Const | Ident] the message being sent to the implicit receiver
2932 2933 2934 |
# File 'lib/syntax_tree/node.rb', line 2932 def @message end |
Instance Method Details
#accept(visitor) ⇒ Object
2947 2948 2949 |
# File 'lib/syntax_tree/node.rb', line 2947 def accept(visitor) visitor.visit_command(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2951 2952 2953 |
# File 'lib/syntax_tree/node.rb', line 2951 def child_nodes [, arguments] end |
#deconstruct_keys(_keys) ⇒ Object
2957 2958 2959 2960 2961 2962 2963 2964 |
# File 'lib/syntax_tree/node.rb', line 2957 def deconstruct_keys(_keys) { message: , arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2966 2967 2968 2969 2970 2971 |
# File 'lib/syntax_tree/node.rb', line 2966 def format(q) q.group do q.format() align(q, self) { q.format(arguments) } end end |