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, ocr_space: "https://api.ocr.space/parse/image") ⇒ FromFile
constructor
A new instance of FromFile.
- #text_data ⇒ Object
Constructor Details
#initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil, ocr_space: "https://api.ocr.space/parse/image") ⇒ FromFile
Returns a new instance of FromFile.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ocr_space/from_file.rb', line 7 def initialize(apikey: ENV['ocr_api_key'], language: 'eng', isOverlayRequired: false, files: nil, ocr_space: "https://api.ocr.space/parse/image") @file = File.new(files) @data = OcrSpace::FilePost.post("/parse/image", body: { apikey: apikey, language: language, isOverlayRequired: isOverlayRequired, files: @file}) @data = @data.data.parsed_response["ParsedResults"][0] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/ocr_space/from_file.rb', line 6 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 self.data.parsed_response["ParsedResults"][0]["ParsedText"] end |