lib/html2rss/feed_builder.rb in html2rss-0.3.3 vs lib/html2rss/feed_builder.rb in html2rss-0.4.0
- old
+ new
@@ -1,16 +1,16 @@
require 'rss'
require_relative 'item'
module Html2rss
class FeedBuilder
- attr_reader :config
-
- def initialize(feed_config)
- @config = feed_config
+ def initialize(config)
+ @config = config
end
+ ##
+ # @return [RSS:Rss]
def rss
RSS::Maker.make('2.0') do |maker|
add_channel_to_maker(maker)
feed_items.map do |feed_item|
@@ -19,13 +19,15 @@
end
end
private
+ attr_reader :config
+
def add_channel_to_maker(maker)
%i[language author title description link ttl].each do |attribute_name|
- maker.channel.send("#{attribute_name}=".to_sym, config.send(attribute_name))
+ maker.channel.public_send("#{attribute_name}=".to_sym, config.public_send(attribute_name))
end
maker.channel.generator = "html2rss V. #{::Html2rss::VERSION}"
maker.channel.lastBuildDate = Time.now.to_s
end
@@ -37,10 +39,10 @@
def add_item_to_items(feed_item, items)
return unless feed_item.valid?
items.new_item do |rss_item|
feed_item.available_attributes.each do |attribute_name|
- rss_item.send("#{attribute_name}=".to_sym, feed_item.send(attribute_name))
+ rss_item.public_send("#{attribute_name}=".to_sym, feed_item.public_send(attribute_name))
end
feed_item.categories.each do |category|
rss_item.categories.new_category.content = category
end