class Elrec::Indexer
Public Class Methods
new(host = "localhost", port = 1056)
click to toggle source
# File lib/elrec/indexer.rb, line 6 def initialize(host = "localhost", port = 1056) @host = host @port = port self.connect end
Public Instance Methods
close()
click to toggle source
# File lib/elrec/indexer.rb, line 23 def close @socket.write("\n") @socket.close end
connect()
click to toggle source
# File lib/elrec/indexer.rb, line 12 def connect @socket = TCPSocket.open(@host, @port) end
index(user_id, item_id)
click to toggle source
# File lib/elrec/indexer.rb, line 16 def index(user_id, item_id) json = "{'userId' : #{user_id}, " + "'itemId' : #{item_id}}\n" @socket.write(json) return @socket.gets end