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.
2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 |
# File 'lib/syntax_tree/node.rb', line 2934 def initialize( receiver:, operator:, message:, arguments:, location:, comments: [] ) @receiver = receiver @operator = operator @message = @arguments = arguments @location = location @comments = comments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
- nil | Args
-
the arguments going along with the message
2929 2930 2931 |
# File 'lib/syntax_tree/node.rb', line 2929 def arguments @arguments end |
#comments ⇒ Object (readonly)
- Array[ Comment | EmbDoc ]
-
the comments attached to this node
2932 2933 2934 |
# File 'lib/syntax_tree/node.rb', line 2932 def comments @comments end |
#message ⇒ Object (readonly)
- Const | Ident | Op
-
the message being send
2926 2927 2928 |
# File 'lib/syntax_tree/node.rb', line 2926 def @message end |
#operator ⇒ Object (readonly)
- :“::” | Op | Period
-
the operator used to send the message
2923 2924 2925 |
# File 'lib/syntax_tree/node.rb', line 2923 def operator @operator end |
#receiver ⇒ Object (readonly)
- untyped
-
the receiver of the message
2920 2921 2922 |
# File 'lib/syntax_tree/node.rb', line 2920 def receiver @receiver end |
Instance Method Details
#accept(visitor) ⇒ Object
2950 2951 2952 |
# File 'lib/syntax_tree/node.rb', line 2950 def accept(visitor) visitor.visit_command_call(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
2954 2955 2956 |
# File 'lib/syntax_tree/node.rb', line 2954 def child_nodes [receiver, , arguments] end |
#deconstruct_keys(keys) ⇒ Object
2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 |
# File 'lib/syntax_tree/node.rb', line 2960 def deconstruct_keys(keys) { receiver: receiver, operator: operator, message: , arguments: arguments, location: location, comments: comments } end |
#format(q) ⇒ Object
2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 |
# File 'lib/syntax_tree/node.rb', line 2971 def format(q) q.group do doc = q.nest(0) do q.format(receiver) q.format(CallOperatorFormatter.new(operator), stackable: false) q.format() end case arguments in Args[parts: [IfOp]] q.if_flat { q.text(" ") } q.format(arguments) in Args q.text(" ") q.nest(argument_alignment(q, doc)) { q.format(arguments) } else # If there are no arguments, print nothing. end end end |