Sha256: 2449db63ed8d719b91c083c66f386b7176835a4be37b32abb9c072ed6a1b982b

Contents?: true

Size: 444 Bytes

Versions: 2

Compression:

Stored size: 444 Bytes

Contents

module FeedDuck
  class Parser
    attr_reader :feed

    def initialize(feed)
      @feed = feed
    end

    def self.parse(feed)
      new(feed).parse
    end

    def parse
      parsed_feed = RSS::Parser.parse(feed)
      map_feed(parsed_feed)
    end

    private

    def map_feed(parsed_feed)
      if parsed_feed.is_a?(RSS::Rss)
        RSSFeed.new(parsed_feed)
      else
        AtomFeed.new(parsed_feed)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
feed_duck-0.0.2 lib/feed_duck/parser.rb
feed_duck-0.0.1 lib/feed_duck/parser.rb