Class: FeedParser::AtomItem
- Defined in:
- lib/feedparser/feedparser.rb
Instance Attribute Summary
Attributes inherited from FeedItem
#cacheditem, #categories, #content, #creators, #date, #enclosures, #feed, #link, #links, #subject, #title, #xml
Instance Method Summary collapse
Methods inherited from FeedItem
#creator, #initialize, #to_html, #to_html_with_headers, #to_s, #to_text
Constructor Details
This class inherits a constructor from FeedParser::FeedItem
Instance Method Details
#parse(item) ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/feedparser/feedparser.rb', line 324 def parse(item) # Title if (e = item.elements['title']) && e.text @title = e.text.unescape_html.toUTF8(@feed.encoding).html2text.rmWhiteSpace! end # Link item.each_element('link') do |e| if (h = e.attribute('href')) && h.value self.link = h.value if e.attribute('type') @links << {:href => h.value, :type => e.attribute('type').value} else @links << {:href => h.value, :type => ''} end end end # Content if e = item.elements['content'] || item.elements['summary'] if (e.attribute('mode') and e.attribute('mode').value == 'escaped') && e.text @content = e.text.toUTF8(@feed.encoding).rmWhiteSpace! else @content = FeedParser::getcontent(e, @feed) end end # Date if (e = item.elements['issued'] || e = item.elements['created'] || e = item.elements['updated'] || e = item.elements['published']) && e.text begin @date = Time::xmlschema(e.text) rescue begin @date = Time::rfc2822(e.text) rescue begin @date = Time::parse(e.text) rescue @date = nil end end end end # Creator item.each_element('author/name') do |e| if e.text @creators << e.text.unescape_html.toUTF8(@feed.encoding).rmWhiteSpace! end end @creators << @feed.creator if @creators.empty? and @feed.creator # Categories item.each_element('category') do |e| if (h = e.attribute('term')) && h.value # Use human-readable label if it is provided if (l = e.attribute('label')) && l.value cat = l.value else cat = h.value end @categories << cat.unescape_html.toUTF8(@feed.encoding).rmWhiteSpace! end end end |