Sha256: a18b4d517efc787d0b9a3b79e0c6bf1ec3cdcf2dbeceba350153039b6eacbaa1

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

Contents

module RRImm
  module ItemFormatter
    class Mail

      attr_accessor :dest, :sender

      def initialize(hash)
        @dest = hash[:to]
        @sender = hash[:from]
      end

      def from(item)
        if item.author and item.author.include? '@'
          item.author
        else
          @sender
        end
      end

      def subject(feed, item, feed_config)
        subject = item.title
        subject = "[#{feed_config.category}]#{item.title}" if feed_config.category
        subject
      end

      def format(feed, item, feed_config, pipe)
        pipe.write "From: #{from(item)}\n"
        pipe.write "To: #{dest}\n"
        pipe.write "Subject: #{subject(feed, item, feed_config)}\n"
        pipe.write "Content-Type: text/html;\n"
        pipe.write "\n"
        pipe.write item.url
        pipe.write "\n\n"
        pipe.write (item.content || item.summary)
        pipe.write "\n"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rrimm-0.2.0 lib/rrimm/item_formatter/mail.rb