Class: FeedMe::FeedParser

Inherits:
AbstractParser show all
Defined in:
lib/feed_me/feed_parser.rb

Direct Known Subclasses

AtomFeedParser, Rss2FeedParser

Instance Attribute Summary

Attributes inherited from AbstractParser

#format, #properties, #xml

Class Method Summary collapse

Methods inherited from AbstractParser

build, #initialize, #to_hash

Constructor Details

This class inherits a constructor from FeedMe::AbstractParser

Class Method Details

.open(file) ⇒ Object



9
10
11
# File 'lib/feed_me/feed_parser.rb', line 9

def open(file)
  self.parse(Kernel.open(file).read)
end

.parse(feed) ⇒ Object

parses the passed feed and identifeis what kind of feed it is then returns a parser object

Raises:



15
16
17
18
19
20
21
22
# File 'lib/feed_me/feed_parser.rb', line 15

def parse(feed)
  xml = Hpricot.XML(feed)

  root_node, format = self.identify(xml)
  raise InvalidFeedFormat if format.nil?

  self.build(root_node, format)
end