Class: OcrSpace::FromFile
- Inherits:
-
Object
- Object
- OcrSpace::FromFile
- Defined in:
- lib/ocr_space/from_file.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil) ⇒ FromFile
constructor
A new instance of FromFile.
- #text_data ⇒ Object
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
#data ⇒ Object (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_data ⇒ Object
16 17 18 |
# File 'lib/ocr_space/from_file.rb', line 16 def text_data data[0]['ParsedText'].delete("\n").delete("\r").strip end |