class SyntaxTree::Command

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

Attributes

arguments[R]
Args

the arguments being sent with the message

block[R]
nil | BlockNode

the optional block being passed to the method

comments[R]
Array[ Comment | EmbDoc ]

the comments attached to this node

message[R]
Const | Ident

the message being sent to the implicit receiver

Public Class Methods

new(message:, arguments:, block:, location:) click to toggle source
# File lib/syntax_tree/node.rb, line 3464
def initialize(message:, arguments:, block:, location:)
  @message = message
  @arguments = arguments
  @block = block
  @location = location
  @comments = []
end

Public Instance Methods

===(other) click to toggle source
# File lib/syntax_tree/node.rb, line 3514
def ===(other)
  other.is_a?(Command) && message === other.message &&
    arguments === other.arguments && block === other.block
end
accept(visitor) click to toggle source
# File lib/syntax_tree/node.rb, line 3472
def accept(visitor)
  visitor.visit_command(self)
end
arity() click to toggle source
# File lib/syntax_tree/node.rb, line 3519
def arity
  arguments.arity
end
child_nodes() click to toggle source
# File lib/syntax_tree/node.rb, line 3476
def child_nodes
  [message, arguments, block]
end
Also aliased as: deconstruct
copy(message: nil, arguments: nil, block: nil, location: nil) click to toggle source
# File lib/syntax_tree/node.rb, line 3480
def copy(message: nil, arguments: nil, block: nil, location: nil)
  node =
    Command.new(
      message: message || self.message,
      arguments: arguments || self.arguments,
      block: block || self.block,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end
deconstruct()
Alias for: child_nodes
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/node.rb, line 3495
def deconstruct_keys(_keys)
  {
    message: message,
    arguments: arguments,
    block: block,
    location: location,
    comments: comments
  }
end
format(q) click to toggle source
# File lib/syntax_tree/node.rb, line 3505
def format(q)
  q.group do
    q.format(message)
    align(q, self) { q.format(arguments) }
  end

  q.format(block) if block
end