class Elrec::Searcher
Public Class Methods
new(host = "localhost", port = 1055)
click to toggle source
# File lib/elrec/searcher.rb, line 6 def initialize(host = "localhost", port = 1055) @host = host @port = port self.connect end
Public Instance Methods
close()
click to toggle source
# File lib/elrec/searcher.rb, line 43 def close @socket.write("\n") @socket.close end
connect()
click to toggle source
# File lib/elrec/searcher.rb, line 12 def connect @socket = TCPSocket.open(@host, @port) end
recommend_from_item_id(item_id, how_many, include_known_items)
click to toggle source
# File lib/elrec/searcher.rb, line 25 def recommend_from_item_id(item_id, how_many, include_known_items) json = "{'inputType' : 'item_id', " + "'itemId' : #{item_id}, " + "'howMany' : #{how_many}, " + "'includeKnownItems' : #{include_known_items}}\n" @socket.write(json) return @socket.gets end
recommend_from_item_list(item_list, how_many, include_known_items)
click to toggle source
# File lib/elrec/searcher.rb, line 34 def recommend_from_item_list(item_list, how_many, include_known_items) json = "{'inputType' : 'item_id_list', " + "'itemIdList' : #{item_list}, " + "'howMany' : #{how_many}, " + "'includeKnownItems' : #{include_known_items}}\n" @socket.write(json) return @socket.gets end
recommend_from_user_id(user_id, how_many, include_known_items)
click to toggle source
# File lib/elrec/searcher.rb, line 16 def recommend_from_user_id(user_id, how_many, include_known_items) json = "{'inputType' : 'user_id', " + "'userId' : #{user_id}, " + "'howMany' : #{how_many}, " + "'includeKnownItems' : #{include_known_items}}\n" @socket.write(json) return @socket.gets end