Sha256: d32a1c3207c7239fc2b6d3fc16727deb437f6919c3db9c7264ccc722460ade0f

Contents?: true

Size: 1022 Bytes

Versions: 2

Compression:

Stored size: 1022 Bytes

Contents

module RRImm
  class Feed
 
    attr_accessor :name
    attr_accessor :uri
    attr_accessor :formatter_class, :formatter
    attr_accessor :category
    attr_accessor :pipe

    def initialize(name)
      @name = name
      @uri = name
      @formatter_class = RRImm::ItemFormatter::Default
    end

    def format(feed, item)
      @formatter ||= @formatter_class.new
      cmd = %Q<#{pipe}>
      IO.popen(cmd,'w+') do |pipe|
        @formatter.format(feed, item, self, pipe)
        pipe.close_write
        pipe.read.split("\n").each { |l| puts l }
      end
    end

    def category(arg=nil)
      if arg
        @category = arg
      end
      @category
    end

    def uri(arg=nil)
      if arg
        @uri = arg
      end
      @uri
    end

    def default_name?
      @name.eql? @uri
    end

    def formatter_class(arg=nil)
      if arg
        @formatter_class = arg
      end
      @formatter_class
    end

    def pipe(arg=nil)
      if arg
        @pipe = arg
      end
      @pipe
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rrimm-0.4.0 lib/rrimm/feed.rb
rrimm-0.3.0 lib/rrimm/feed.rb