Class: SyntaxTree::CommandCall
Overview
CommandCall represents a method call on an object with arguments and no parentheses.
object.method argument
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
- nil | Args
-
the arguments going along with the message.
-
#comments ⇒ Object
readonly
- Array[ Comment | EmbDoc ]
-
the comments attached to this node.
-
#message ⇒ Object
readonly
- Const | Ident | Op
-
the message being send.
-
#operator ⇒ Object
readonly
- :“::” | Op | Period
-
the operator used to send the message.
-
#receiver ⇒ Object
readonly
- untyped
-
the receiver of the message.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #child_nodes ⇒ Object (also: #deconstruct)
- #deconstruct_keys(keys) ⇒ Object
- #format(q) ⇒ Object
-
#initialize(receiver:, operator:, message:, arguments:, location:, comments: []) ⇒ CommandCall
constructor
A new instance of CommandCall.
Methods inherited from Node
Constructor Details
#initialize(receiver:, operator:, message:, arguments:, location:, comments: []) ⇒ CommandCall
Returns a new instance of CommandCall.
2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 |
# File 'lib/syntax_tree/node.rb', line 2591 def initialize( receiver:, operator:, message:, arguments:, location:, comments: [] ) @receiver = receiver @operator = operator = @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- nil | Args
-
the arguments going along with the message
2586 2587 2588 |
# File 'lib/syntax_tree/node.rb', line 2586 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2589 2590 2591 |
# File 'lib/syntax_tree/node.rb', line 2589 def comments @comments end |
#message ⇒ Object (readonly)
- Const | Ident | Op
-
the message being send
2583 2584 2585 |
# File 'lib/syntax_tree/node.rb', line 2583 def end |
#operator ⇒ Object (readonly)
- :“::” | Op | Period
-
the operator used to send the message
2580 2581 2582 |
# File 'lib/syntax_tree/node.rb', line 2580 def operator @operator end |
#receiver ⇒ Object (readonly)
- untyped
-
the receiver of the message
2577 2578 2579 |
# File 'lib/syntax_tree/node.rb', line 2577 def receiver @receiver end |
Instance Method Details
#accept(visitor) ⇒ Object
2607 2608 2609 |
# File 'lib/syntax_tree/node.rb', line 2607 def accept(visitor) visitor.visit_command_call(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2611 2612 2613 |
# File 'lib/syntax_tree/node.rb', line 2611 def child_nodes [receiver, , arguments] end |
#deconstruct_keys(keys) ⇒ Object
2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 |
# File 'lib/syntax_tree/node.rb', line 2617 def deconstruct_keys(keys) { receiver: receiver, operator: operator, message: , arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 |
# File 'lib/syntax_tree/node.rb', line 2628 def format(q) q.group do doc = q.nest(0) do q.format(receiver) q.format(CallOperatorFormatter.new(operator), stackable: false) q.format() end if arguments q.text(" ") q.nest(argument_alignment(q, doc)) { q.format(arguments) } end end end |