class Plaintext::RtfHandler
Constants
- DEFAULT
- END_MARKER
- UNRTF_HEADER
Public Class Methods
new()
click to toggle source
# File lib/plaintext/file_handler/external_command_handler/rtf_handler.rb, line 8 def initialize @content_type = 'application/rtf' @command = Plaintext::Configuration['unrtf'] || DEFAULT end
Private Instance Methods
read(io, max_size = nil)
click to toggle source
# File lib/plaintext/file_handler/external_command_handler/rtf_handler.rb, line 18 def read(io, max_size = nil) if line = io.read(UNRTF_HEADER.length) string = if line.starts_with? UNRTF_HEADER io.gets while $_ != END_MARKER io.read max_size else if max_size.nil? line + io.read elsif max_size > UNRTF_HEADER.length line + io.read(max_size - UNRTF_HEADER.length) else line[0,max_size] end end Plaintext::CodesetUtil.to_utf8 string, "ASCII-8BIT" end end