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
Constructor Details
#initialize(message:, arguments:, location:, comments: []) ⇒ Command
Returns a new instance of Command.
2861 2862 2863 2864 2865 2866 |
# File 'lib/syntax_tree/node.rb', line 2861 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
2856 2857 2858 |
# File 'lib/syntax_tree/node.rb', line 2856 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2859 2860 2861 |
# File 'lib/syntax_tree/node.rb', line 2859 def comments @comments end |
#message ⇒ Object (readonly)
- Const | Ident
-
the message being sent to the implicit receiver
2853 2854 2855 |
# File 'lib/syntax_tree/node.rb', line 2853 def @message end |
Instance Method Details
#accept(visitor) ⇒ Object
2868 2869 2870 |
# File 'lib/syntax_tree/node.rb', line 2868 def accept(visitor) visitor.visit_command(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2872 2873 2874 |
# File 'lib/syntax_tree/node.rb', line 2872 def child_nodes [, arguments] end |
#deconstruct_keys(keys) ⇒ Object
2878 2879 2880 2881 2882 2883 2884 2885 |
# File 'lib/syntax_tree/node.rb', line 2878 def deconstruct_keys(keys) { message: , arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2887 2888 2889 2890 2891 2892 |
# File 'lib/syntax_tree/node.rb', line 2887 def format(q) q.group do q.format() align(q, self) { q.format(arguments) } end end |