Sha256: 6dea8b966e25f9b0e8738ec6bfa6f9aff9ac904d3a76f3db3d897b738c1d97a1

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

require 'mail'

module Email; end

module Email::Mboxrd
  class Message
    def initialize(body)
      @body = body.clone
      @body.force_encoding('binary') if RUBY_VERSION >= '1.9.0'
    end

    def to_s
      'From ' + from + "\n" + body + "\n"
    end

    private

    def parsed
      @parsed ||= Mail.new(@body)
    end

    def from
      parsed.from[0] + ' ' + asctime
    end

    def body
      mbox = @body.gsub(/\n(>*From)/, "\n>\\1")
      mbox += "\n" unless mbox.end_with?("\n")
      mbox
    end

    def asctime
      parsed.date.asctime
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
imap-backup-1.0.10 lib/email/mboxrd/message.rb