Module: Mindee::Input::Source

Defined in:
lib/mindee.rb,
lib/mindee/input/sources/url_input_source.rb,
lib/mindee/input/sources/file_input_source.rb,
lib/mindee/input/sources/path_input_source.rb,
lib/mindee/input/sources/bytes_input_source.rb,
lib/mindee/input/sources/local_input_source.rb,
lib/mindee/input/sources/base64_input_source.rb

Overview

Document source handling.

Defined Under Namespace

Classes: Base64InputSource, BytesInputSource, FileInputSource, InvalidMimeTypeError, LocalInputSource, MimeTypeError, PathInputSource, UnfixablePDFError, UrlInputSource

Constant Summary collapse

ALLOWED_MIME_TYPES =

Mime types accepted by the server.

[
  'application/pdf',
  'image/heic',
  'image/png',
  'image/jpeg',
  'image/tiff',
  'image/webp',
].freeze

Class Method Summary collapse

Class Method Details

.convert_to_unicode_escape(string) ⇒ Object

Replaces non-ASCII characters by their UNICODE escape sequence. Keeps other characters as is.

Returns:

  • A clean String.



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/mindee/input/sources/local_input_source.rb', line 170

def self.convert_to_unicode_escape(string)
  unicode_escape_string = ''.dup
  string.each_char do |char|
    unicode_escape_string << if char.bytesize > 1
                               "\\u#{char.unpack1('U').to_s(16).rjust(4, '0')}"
                             else
                               char
                             end
  end
  unicode_escape_string
end