module Redis::Connection::CommandHelper

Constants

COMMAND_DELIMITER

Public Instance Methods

build_command(args) click to toggle source
# File lib/redis/connection/command_helper.rb, line 7
def build_command(args)
  command = [nil]

  args.each do |i|
    if i.is_a? Array
      i.each do |j|
        j = j.to_s
        command << "$#{j.bytesize}"
        command << j
      end
    else
      i = i.to_s
      command << "$#{i.bytesize}"
      command << i
    end
  end

  command[0] = "*#{(command.length - 1) / 2}"

  # Trailing delimiter
  command << ""
  command.join(COMMAND_DELIMITER)
end

Protected Instance Methods

encode(string) click to toggle source
# File lib/redis/connection/command_helper.rb, line 34
def encode(string)
  string.force_encoding(Encoding::default_external)
end