Sha256: ac5273b8e698c7308a2b2f2cbc7f0d20dd67ffe978f9190e54a29dbe8c4d70ea

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

module EmailSpec
  module Extractors
    class Base
      attr_accessor :mail

      def initialize(mail)
        @mail = mail
      end

      def call
        part_body ? HTMLEntities.new.decode(part_body) : ''
      end

      private

      def part_body
        raise NotImplementedError
      end
    end

    class DefaultPartBody < Base
      private

      def part_body
        (mail.html_part || mail.text_part || mail).body
      end
    end

    class HtmlPartBody < Base
      private

      def part_body
        mail.html_part ? mail.html_part.body : nil
      end
    end

    class TextPartBody < Base
      private

      def part_body
        mail.text_part ? mail.text_part.body : nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
email_spec-2.3.0 lib/email_spec/extractors.rb