Class: NSILapesi::Searcher
- Inherits:
-
Object
- Object
- NSILapesi::Searcher
- Defined in:
- lib/nsi-lapesi/searcher.rb
Instance Method Summary collapse
-
#initialize ⇒ Searcher
constructor
A new instance of Searcher.
- #search_image(image, limit = 5) ⇒ Object
Constructor Details
#initialize ⇒ Searcher
Returns a new instance of Searcher.
9 10 11 12 |
# File 'lib/nsi-lapesi/searcher.rb', line 9 def initialize params = Configuration.settings @server = XMLRPC::Client.new(params[:host], params[:path], params[:port]) end |
Instance Method Details
#search_image(image, limit = 5) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/nsi-lapesi/searcher.rb', line 14 def search_image(image, limit = 5) if image.class == String image_content = Base64.decode64(image) else image.seek 0 image_content = image.read end results_xml = @server.call("ImageSearcher.searchImage", XMLRPC::Base64.new(image_content), limit) results = XmlSimple.xml_in results_xml (results['code'] == '100')? results['item'] : [] end |