class RRImm::FeedConfig
Attributes
category[RW]
formatter[RW]
formatter_class[RW]
massages[RW]
name[RW]
publisher[RW]
uri[RW]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/rrimm/feed_config.rb, line 14 def initialize(name, &block) @name = name @uri = name @formatter_class = RRImm::ItemFormatter::Default @massages = [] self.instance_eval(&block) if block end
Public Instance Methods
default_name?()
click to toggle source
# File lib/rrimm/feed_config.rb, line 61 def default_name? @name.eql? @uri end
format(feed, item)
click to toggle source
# File lib/rrimm/feed_config.rb, line 38 def format(feed, item) @formatter ||= @formatter_class.new formatted_feed = "" StringIO.open(formatted_feed) do |str| @formatter.format(feed,item, self, str) end publisher.publish(formatted_feed, feed, item) end
massage(feed)
click to toggle source
may apply modifications on feeds must return an enumerable of feeditems massage method applies @massages keys as methods on “feed” it also uses the value as a block if a block is given
# File lib/rrimm/feed_config.rb, line 26 def massage(feed) @massages.inject(feed) do |mem, method_with_arg| arg = method_with_arg.values.first method = method_with_arg.keys.first if arg mem.send(method, &arg) else mem.send(method) end end end
pipe(arg=nil)
click to toggle source
compat with old pipe
# File lib/rrimm/feed_config.rb, line 80 def pipe(arg=nil) if arg publisher RRImm::Pipe.new(arg) end publisher.command end