Parent

EventMachine::Hiredis::Connection

Constants

COMMAND_DELIMITER

Public Class Methods

new(host, port) click to toggle source
# File lib/em-hiredis/connection.rb, line 7
def initialize(host, port)
  super
  @host, @port = host, port
  @name = "[em-hiredis #{@host}:#{@port}]"
end

Public Instance Methods

connection_completed() click to toggle source
# File lib/em-hiredis/connection.rb, line 18
def connection_completed
  @reader = ::Hiredis::Reader.new
  emit(:connected)
end
receive_data(data) click to toggle source
# File lib/em-hiredis/connection.rb, line 23
def receive_data(data)
  @reader.feed(data)
  until (reply = @reader.gets) == false
    emit(:message, reply)
  end
end
reconnect(host, port) click to toggle source
# File lib/em-hiredis/connection.rb, line 13
def reconnect(host, port)
  super
  @host, @port = host, port
end
send_command(command, args) click to toggle source
# File lib/em-hiredis/connection.rb, line 34
def send_command(command, args)
  send_data(command(command, *args))
end
to_s() click to toggle source
# File lib/em-hiredis/connection.rb, line 38
def to_s
  @name
end
unbind() click to toggle source
# File lib/em-hiredis/connection.rb, line 30
def unbind
  emit(:closed)
end

Protected Instance Methods

command(*args) click to toggle source
# File lib/em-hiredis/connection.rb, line 46
def command(*args)
  command = []
  command << "*#{args.size}"

  args.each do |arg|
    arg = arg.to_s
    command << "$#{string_size arg}"
    command << arg
  end

  command.join(COMMAND_DELIMITER) + COMMAND_DELIMITER
end
string_size(string) click to toggle source
# File lib/em-hiredis/connection.rb, line 60
def string_size(string)
  string.to_s.bytesize
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.