Class: FeedUtils::Parser
- Inherits:
-
Object
- Object
- FeedUtils::Parser
- Includes:
- LogUtils::Logging
- Defined in:
- lib/feedutils/utils.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
138 139 140 |
# File 'lib/feedutils/utils.rb', line 138 def initialize( xml ) @xml = xml end |
Class Method Details
.parse(xml, opts = {}) ⇒ Object
convenience class/factory method
163 164 165 |
# File 'lib/feedutils/utils.rb', line 163 def self.parse( xml, opts={} ) self.new( xml ).parse end |
Instance Method Details
#parse ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/feedutils/utils.rb', line 142 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 |