Class: OcrSpace::FromFile

Inherits:
Object
  • Object
show all
Defined in:
lib/ocr_space/from_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil) ⇒ FromFile

Returns a new instance of FromFile.



6
7
8
9
10
11
12
13
14
# File 'lib/ocr_space/from_file.rb', line 6

def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil)
    @file = File.new(files)
    @data = OcrSpace::FilePost.post('/parse/image',
                                    body: { apikey: apikey,
                                            language: language,
                                            isOverlayRequired: isOverlayRequired,
                                            files: @file })
    @data = @data.parsed_response['ParsedResults']
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/ocr_space/from_file.rb', line 5

def data
  @data
end

Instance Method Details

#text_dataObject



16
17
18
# File 'lib/ocr_space/from_file.rb', line 16

def text_data
    data[0]['ParsedText'].delete("\n").delete("\r").strip
end