Sha256: 29475c86dfb3eb677d6d80866854276e5cec8c7519ff1becc2e855e075a1258f
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
module FeedDuck class RSSFeed def initialize(parsed_feed) @parsed_feed = parsed_feed end def title parsed_feed.channel.title end def url parsed_feed.channel.link end def description parsed_feed.channel.description end def language parsed_feed.channel.language end def entries parsed_feed.items.map do |item| RSSEntry.new(item) end end def to_h attributes_hash.merge(entries: entries.map(&:to_h)) end private attr_reader :parsed_feed def attributes_hash public_attributes.each_with_object(Hash.new) do |attr, attribute_hash| attribute_hash[attr] = send(attr) end end def public_attributes [:title, :url, :description] end end class RSSEntry def initialize(parsed_feed_entry) @parsed_feed_entry = parsed_feed_entry end def title parsed_feed_entry.title end def content parsed_feed_entry.description end def published_at parsed_feed_entry.pubDate end def author parsed_feed_entry.author end def url parsed_feed_entry.link end def uuid parsed_feed_entry.guid.content end def to_h public_attributes.each_with_object(Hash.new) do |attr, attribute_hash| attribute_hash[attr] = send(attr) end end private attr_reader :parsed_feed_entry def public_attributes [:title, :content, :published_at, :author, :url, :uuid] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
feed_duck-0.0.2 | lib/feed_duck/rss_feed.rb |