lib/html2rss/item.rb in html2rss-0.1.0 vs lib/html2rss/item.rb in html2rss-0.2.0
- old
+ new
@@ -30,17 +30,21 @@
value
end
def available_attributes
- # TODO: support optional attributes, e.g. category, enclosure, source
- @available_attributes ||= (%w[title link description author comments updated] & @config.attribute_names)
+ @available_attributes ||= (%w[title link description author comments updated] &
+ @config.attribute_names) - ['categories']
end
def valid?
return false if [title.to_s, description.to_s].join('') == ''
true
+ end
+
+ def categories
+ config.categories.map(&method(:method_missing)).uniq.keep_if { |category| category.to_s != '' }
end
def self.from_url(url, config)
connection = Faraday.new(url: url, headers: config.headers)
page = Nokogiri::HTML(connection.get.body)