Class: Aspose::Cloud::Barcode::Reader
- Inherits:
-
Object
- Object
- Aspose::Cloud::Barcode::Reader
- Defined in:
- lib/Barcode/reader.rb
Instance Method Summary collapse
-
#initialize(filename) ⇒ Reader
constructor
A new instance of Reader.
- #read(symbology) ⇒ Object
- #read_from_local_image(local_image, remote_folder, barcode_read_type, format) ⇒ Object
- #readr(remote_image_name, remote_folder, read_type, format) ⇒ Object
- #uri_builder(remote_image, remote_folder, read_type, format) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Reader
Returns a new instance of Reader.
5 6 7 |
# File 'lib/Barcode/reader.rb', line 5 def initialize filename @filename = filename end |
Instance Method Details
#read(symbology) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/Barcode/reader.rb', line 9 def read symbology begin if @filenmae == '' raise 'Base file is not specified' end str_uri = $product_uri + '/barcode/' + @filename + '/recognize?' + (symbology <= 0 ? 'type=' : 'type=' + symbology.to_s) signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri,:accept => 'application/json') json = JSON.parse(response) if(json['Code']== 200) return json['Barcodes'] else return nil end rescue Exception=>e print e end end |
#read_from_local_image(local_image, remote_folder, barcode_read_type, format) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/Barcode/reader.rb', line 28 def read_from_local_image local_image, remote_folder, ,format begin if @filename=='' raise 'Base file is not specified.' end folder = Aspose::Cloud::AsposeStorage::Folder.new folder.upload_file(local_image,remote_folder) data = readr(File.basename(local_image), remote_folder, ,format) return data rescue Exception=>e print e end end |
#readr(remote_image_name, remote_folder, read_type, format) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/Barcode/reader.rb', line 42 def readr remote_image_name,remote_folder,read_type,format begin if @filename == '' raise 'Base file is not specified' end str_uri = uri_builder(remote_image_name, remote_folder, read_type,format) signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) response = RestClient.get(signed_uri , :accept=>'application/json') json = JSON.parse(response) if(json['Code']==200) return json['Barcodes'] else return nil end rescue Exception=>e print e end end |
#uri_builder(remote_image, remote_folder, read_type, format) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/Barcode/reader.rb', line 62 def uri_builder remote_image,remote_folder,read_type,format uri = $product_uri + '/barcode/' if remote_image != nil && remote_image!='' uri += remote_image + '/' end uri += 'recognize?' if read_type == 'AllSupportedTypes' uri += 'type=' else uri += 'type=' + read_type.to_s; end if format != nil && format != '' uri += '&format=' + format; end if remote_folder != nil && remote_folder != '' uri += '&folder=' + remote_folder; end return uri; end |