Class: FeedUtils::Parser
- Inherits:
-
Object
- Object
- FeedUtils::Parser
- Includes:
- LogUtils::Logging
- Defined in:
- lib/feedutils/parser.rb
Class Method Summary collapse
-
.parse(xml, opts = {}) ⇒ Object
convenience class/factory method.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Parser
constructor
Note: lets keep/use same API as RSS::Parser for now.
- #parse ⇒ Object
Constructor Details
#initialize(xml) ⇒ Parser
Note: lets keep/use same API as RSS::Parser for now
15 16 17 |
# File 'lib/feedutils/parser.rb', line 15 def initialize( xml ) @xml = xml end |
Class Method Details
.parse(xml, opts = {}) ⇒ Object
convenience class/factory method
10 11 12 |
# File 'lib/feedutils/parser.rb', line 10 def self.parse( xml, opts={} ) self.new( xml ).parse end |
Instance Method Details
#parse ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/feedutils/parser.rb', line 19 def parse parser = RSS::Parser.new( @xml ) parser.do_validate = false parser.ignore_unknown_element = true puts "Parsing feed..." feed_wild = parser.parse # not yet normalized logger.debug " feed.class=#{feed_wild.class.name}" if feed_wild.is_a?( RSS::Atom::Feed ) feed = AtomFeedBuilder.build( feed_wild ) else # -- assume RSS::Rss::Feed feed = RssFeedBuilder.build( feed_wild ) end puts "== #{feed.format} / #{feed.title} ==" feed # return new (normalized) feed end |