0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.