Class: NSILapesi::Indexer
- Inherits:
-
Object
- Object
- NSILapesi::Indexer
- Defined in:
- lib/nsi-lapesi/indexer.rb
Constant Summary collapse
- MIMETYPES =
['jpeg', 'jpg']
Instance Method Summary collapse
- #add_image(params = {}) ⇒ Object
- #del_image(id) ⇒ Object
-
#initialize ⇒ Indexer
constructor
A new instance of Indexer.
Constructor Details
#initialize ⇒ Indexer
Returns a new instance of Indexer.
13 14 15 16 |
# File 'lib/nsi-lapesi/indexer.rb', line 13 def initialize params = Configuration.settings @server = XMLRPC::Client.new(params[:host], params[:path], params[:port]) end |
Instance Method Details
#add_image(params = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nsi-lapesi/indexer.rb', line 18 def add_image(params = {}) params = {image: '', id: '', author: 'Lapesi', title: 'LapesiImage', format: 'jpg', type: 'Artigo', keywords: ['lapesi'], publicationdate: ''}.merge(params) image = params.delete(:image) contract = create_xml_contract params raise Errors::ImageFormatNotSupported if not MIMETYPES.include? params[:format] begin if image.class == String image_content = Base64.decode64(image) else image.seek 0 image_content = image.read end status_code = @server.call("ImageIndexer.addImage", XMLRPC::Base64.new(contract), XMLRPC::Base64.new(image_content)) rescue Exception => e puts e. status_code = 111 end end |
#del_image(id) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/nsi-lapesi/indexer.rb', line 42 def del_image(id) begin status_code = @server.call("ImageIndexer.delImage", id) rescue Exception => e puts e. status_code = 111 end end |