A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ruby-syntax-tree.github.io/syntax_tree/SyntaxTree/CommandCall.html below:

class SyntaxTree::CommandCall - RDoc Documentation

  1. SyntaxTree::
  2. CommandCall
class SyntaxTree::CommandCall

CommandCall represents a method call on an object with arguments and no parentheses.

object.method argument
Attributes
nil | Args | ArgParen

the arguments going along with the message

nil | BlockNode

the block associated with this method call

nil | :“::” | Op | Period

the operator used to send the message

nil | Node

the receiver of the message

Public Class Methods

Source

def initialize(
  receiver:,
  operator:,
  message:,
  arguments:,
  block:,
  location:
)
  @receiver = receiver
  @operator = operator
  @message = message
  @arguments = arguments
  @block = block
  @location = location
  @comments = []
end
Public Instance Methods

Source

def ===(other)
  other.is_a?(CommandCall) && receiver === other.receiver &&
    operator === other.operator && message === other.message &&
    arguments === other.arguments && block === other.block
end

Source

def accept(visitor)
  visitor.visit_command_call(self)
end

Source

def arity
  arguments&.arity || 0
end

Source

def child_nodes
  [receiver, message, arguments, block]
end

Source

def copy(
  receiver: nil,
  operator: nil,
  message: nil,
  arguments: nil,
  block: nil,
  location: nil
)
  node =
    CommandCall.new(
      receiver: receiver || self.receiver,
      operator: operator || self.operator,
      message: message || self.message,
      arguments: arguments || self.arguments,
      block: block || self.block,
      location: location || self.location
    )

  node.comments.concat(comments.map(&:copy))
  node
end

Source

def deconstruct_keys(_keys)
  {
    receiver: receiver,
    operator: operator,
    message: message,
    arguments: arguments,
    block: block,
    location: location,
    comments: comments
  }
end

Source

def format(q)
  message = self.message
  arguments = self.arguments
  block = self.block

  q.group do
    doc =
      q.nest(0) do
        q.format(receiver)

        
        
        
        if message != :call && message.comments.any?(&:leading?)
          q.format(CallOperatorFormatter.new(operator), stackable: false)
          q.indent do
            q.breakable_empty
            q.format(message)
          end
        else
          q.format(CallOperatorFormatter.new(operator), stackable: false)
          q.format(message)
        end
      end

    
    
    if arguments
      parts = arguments.parts

      if parts.length == 1 && parts.first.is_a?(IfOp)
        q.if_flat { q.text(" ") }
        q.format(arguments)
      else
        q.text(" ")
        q.nest(argument_alignment(q, doc)) { q.format(arguments) }
      end
    end
  end

  q.format(block) if block
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4