Skip to content
Browse files

Include Enumerable and supply basic each, [] and []= methods for Feed…

…zirra::Parser::RSSEntry
  • Loading branch information...
1 parent c54536f commit 041dcd46c0e65e41d69ab6e1256a68936b8f59e5 @semperos semperos committed Sep 22, 2011
Showing with 24 additions and 6 deletions.
  1. +24 −6 lib/feedzirra/parser/rss_entry.rb
View
30 lib/feedzirra/parser/rss_entry.rb
@@ -3,30 +3,48 @@ 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
+end

0 comments on commit 041dcd4

Please sign in to comment.
Something went wrong with that request. Please try again.