Class: Syndication::Atom::Parser
- Inherits:
-
Syndication::AbstractParser
- Object
- Syndication::AbstractParser
- Syndication::Atom::Parser
- Includes:
- REXML::StreamListener
- Defined in:
- lib/syndication/atom.rb
Overview
A parser for Atom feeds. See Syndication::Parser in common.rb for the abstract class this specializes.
Constant Summary collapse
- CLASS_FOR_TAG =
:stopdoc: A hash of tags which require the creation of new objects, and the class to use for creating the object.
{ 'entry' => Entry, 'author' => Person, 'contributor' => Person, 'title' => Data, 'subtitle' => Data, 'summary' => Data, 'link' => Link, 'source' => Feed, 'category' => Category, 'content' => Content }
Constants inherited from Syndication::AbstractParser
Syndication::AbstractParser::KNOWN_NAMESPACES
Instance Method Summary collapse
-
#feed ⇒ Object
The most recently parsed feed as a Syndication::Feed object.
-
#reset ⇒ Object
Reset the parser ready to parse a new feed.
-
#text(s) ⇒ Object
Called when REXML finds a text fragment.
Methods inherited from Syndication::AbstractParser
#cdata, #define_namespace, #end_tag, #handle_namespace, #initialize, #parse, #store, #tag_end, #tag_start
Constructor Details
This class inherits a constructor from Syndication::AbstractParser
Instance Method Details
#feed ⇒ Object
The most recently parsed feed as a Syndication::Feed object.
523 524 525 |
# File 'lib/syndication/atom.rb', line 523 def feed return @parsetree end |
#reset ⇒ Object
Reset the parser ready to parse a new feed.
513 514 515 516 517 518 519 520 |
# File 'lib/syndication/atom.rb', line 513 def reset # Set up an empty Feed object and make it the current object @parsetree = Feed.new(nil) # Set up the class-for-tag hash @class_for_tag = CLASS_FOR_TAG # Everything else is common to both kinds of parser super end |
#text(s) ⇒ Object
Called when REXML finds a text fragment. For Atom parsing, we need to handle Data objects specially: They need all events passed through verbatim, because they might contain XHTML which will be sent through as REXML events and will need to be reconstructed.
501 502 503 504 505 506 507 508 509 |
# File 'lib/syndication/atom.rb', line 501 def text(s) if @current_object.kind_of?(Data) @current_object.text(s) return end if @textstack.last @textstack.last << s end end |