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.
2517 2518 2519 2520 2521 2522 |
# File 'lib/syntax_tree/node.rb', line 2517 def initialize(message:, arguments:, location:, comments: []) = @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- Args
-
the arguments being sent with the message
2512 2513 2514 |
# File 'lib/syntax_tree/node.rb', line 2512 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2515 2516 2517 |
# File 'lib/syntax_tree/node.rb', line 2515 def comments @comments end |
#message ⇒ Object (readonly)
- Const | Ident
-
the message being sent to the implicit receiver
2509 2510 2511 |
# File 'lib/syntax_tree/node.rb', line 2509 def end |
Instance Method Details
#accept(visitor) ⇒ Object
2524 2525 2526 |
# File 'lib/syntax_tree/node.rb', line 2524 def accept(visitor) visitor.visit_command(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2528 2529 2530 |
# File 'lib/syntax_tree/node.rb', line 2528 def child_nodes [, arguments] end |
#deconstruct_keys(keys) ⇒ Object
2534 2535 2536 2537 2538 2539 2540 2541 |
# File 'lib/syntax_tree/node.rb', line 2534 def deconstruct_keys(keys) { message: , arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 |
# File 'lib/syntax_tree/node.rb', line 2543 def format(q) q.group do q.format() q.text(" ") if align?(self) q.nest(.value.length + 1) { q.format(arguments) } else q.format(arguments) end end end |