Sha256: 9a968e881f2952af61aae625966256ee51bf1928ec33b5b48459052328a1f221

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 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.link
        pipe.write "\n\n"
        pipe.write item.content if item.content
        pipe.write "\n"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rrimm-0.1.1 lib/rrimm/item_formatter/mail.rb
rrimm-0.1.0 lib/rrimm/item_formatter/mail.rb