Sha256: 21e6371c5c77f6f54e120249a4bdbcc0fa82eeb0383f2c109c4c3477de4b1ca1

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Feedzirra

  module Parser
    # Parser for dealing with RDF feed entries.
    class RSSEntry
      include Enumerable
      include SAXMachine
      include FeedEntryUtilities

      element :title
      element :link, :as => :url
      
      element :"dc:creator", :as => :author
      element :author, :as => :author
      element :"content:encoded", :as => :content
      element :description, :as => :summary
      
      element :pubDate, :as => :published
      element :pubdate, :as => :published
      element :"dc:date", :as => :published
      element :"dc:Date", :as => :published
      element :"dcterms:created", :as => :published
      
      
      element :"dcterms:modified", :as => :updated
      element :issued, :as => :published
      elements :category, :as => :categories
      
      element :guid, :as => :entry_id
      
      def each
        @rss_fields ||= self.instance_variables

        @rss_fields.each do |field|
          yield(field.to_s.sub('@', ''), self.instance_variable_get(field))
        end
      end

      def [](field)
        self.instance_variable_get("@#{field.to_s}")
      end

      def []=(field, value)
        self.instance_variable_set("@#{field.to_s}", value)
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feedzirra-0.1.0 lib/feedzirra/parser/rss_entry.rb