Class: Plaintext::PlaintextHandler

Inherits:
FileHandler show all
Defined in:
lib/plaintext/file_handler/plaintext_handler.rb

Constant Summary collapse

CONTENT_TYPES =
%w(text/csv text/plain)

Instance Method Summary collapse

Methods inherited from FileHandler

#accept?, #set

Constructor Details

#initializePlaintextHandler

Returns a new instance of PlaintextHandler.



7
8
9
# File 'lib/plaintext/file_handler/plaintext_handler.rb', line 7

def initialize
  @content_types = CONTENT_TYPES
end

Instance Method Details

#text(file, options = {}) ⇒ Object



11
12
13
14
# File 'lib/plaintext/file_handler/plaintext_handler.rb', line 11

def text(file, options = {})
  max_size = options[:max_size]
  Plaintext::CodesetUtil.to_utf8 IO.read(file, max_size), 'UTF-8'
end