Reputation: 2058
I need some help understanding how the Ruby rss parser works. I'm trying to access to the content of the first 10 entries from this feed with this code:
URL = 'http://weblog.rubyonrails.org/feed/atom.xml'
...
def initialize(versionName)
open(URL) do |rss|
feed = RSS::Parser.parse(rss)
feed.entry(1..10).each do |entry|
@attributes[:descriptions][:"#{versionName}"] = entry.content
end
end
end
While debugging, I realized entry.content
doesn't give me the correct data. Instead, it gives me this endless data which even causes my console to get stuck. Anyone could tell what would be the correct way to parse my feed in my situation?
Upvotes: 0
Views: 76
Reputation: 968
entry.content
is an instance of RSS::Atom::Feed::Entry::Content
:
feed.entry(1..10).first.content.class
# => RSS::Atom::Feed::Entry::Content < RSS::Element
It has a bunch of public methods that could allow you to inspect the tag's content, including content
and to_s
. You can inspect it's public methods by looking up the documentation or by doing: entry.content.public_methods
.
Upvotes: 1