class ChupaText::Formatters::Hash
Public Class Methods
Public Instance Methods
Source
# File lib/chupa-text/formatters/hash.rb, line 27 def format_extracted(data) text = {} format_headers(data, text) text["body"] = data.body screenshot = data.screenshot if screenshot text["screenshot"] = { "mime-type" => screenshot.mime_type, "data" => screenshot.data, } if screenshot.encoding text["screenshot"]["encoding"] = screenshot.encoding end end @texts << text end
Source
# File lib/chupa-text/formatters/hash.rb, line 44 def format_finish(data) formatted = {} format_headers(data, formatted) formatted["texts"] = @texts formatted end
Source
# File lib/chupa-text/formatters/hash.rb, line 24 def format_start(data) end
Private Instance Methods
Source
# File lib/chupa-text/formatters/hash.rb, line 67 def format_header(name, value, target) return if value.nil? target[name] = value end
Source
# File lib/chupa-text/formatters/hash.rb, line 52 def format_headers(data, target) format_header("mime-type", data.mime_type, target) format_header("uri", data.uri, target) case data.uri when URI::HTTP, URI::FTP, nil # No path else format_header("path", data.path, target) end format_header("size", data.size, target) data.attributes.each do |name, value| format_header(name, value, target) end end