# Trying to parse an array of rss feeds without success

**URL:** <https://www.ruby-forum.com/t/trying-to-parse-an-array-of-rss-feeds-without-success/157661>\
**Category:** Ruby\
**Created:** [January 14, 2009, 8:04am UTC](https://www.ruby-forum.com/t/trying-to-parse-an-array-of-rss-feeds-without-success/157661 "2009-01-14T08:04:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [January 14, 2009, 8:04am UTC](https://www.ruby-forum.com/t/trying-to-parse-an-array-of-rss-feeds-without-success/157661/1 "2009-01-14T08:04:14Z")

</div>

hey folks,

I’m trying to make a basic feeds parser… It works fine when I have one  
feed only but as soon as I try to parse an array of feeds, it’s gonna  
parse it correctly but I won’t be able to fetch any data out of it…  
Here is my code…

class Site  
attr\_accessor :domain, :name

def initialize  
@domain = domain  
@name = name  
end  
end

a = Site.new  
a.domain = “[http://www.mininova.org/rss.xml](http://www.mininova.org/rss.xml)”  
a.name = “mininova”

b = Site.new  
b.domain = “[http://static.demonoid.com/rss/0.xml](http://static.demonoid.com/rss/0.xml)”  
b.name = “demonoid”

c = Site.new  
c.domain = “[http://rss.thepiratebay.org/0](http://rss.thepiratebay.org/0)”  
c.name = “thepiratebay”

allfeeds = [a, b, c]

require ‘rss/1.0’  
require ‘rss/2.0’  
require ‘open-uri’

def parse\_torrents(source)

# source = self.domain # url or local file

content = “” # raw content of rss feed will be loaded here  
open(source) do |s| content = s.read end  
RSS::Parser.parse(content, false)  
end

torrents = allfeeds.each { |feed| parse\_torrents(feed.domain) }

torrents.each { |t| puts t.channel.title }

The error message I get is only on the last line of code… removing the  
last line doesn’t show any error message.

Here is the message i get from RubyMate:

NoMethodError: undefined method â€˜channelâ€™ for #Site:0x8a520

at top level in global.rb at line 38  
method each in global.rb at line 38  
at top level in global.rb at line 38  
Program exited.

I need help even though it’s a pretty basic question…

Thank you guys…

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [January 14, 2009, 2:39pm UTC](https://www.ruby-forum.com/t/trying-to-parse-an-array-of-rss-feeds-without-success/157661/2 "2009-01-14T14:39:12Z")

</div>

Louis-pierre Lp.dahito schrieb:

> def initialize  
> b = Site.new  
> require ‘rss/2.0’
> 
> method each in global.rb at line 38  
> at top level in global.rb at line 38  
> Program exited.
> 
> I need help even though it’s a pretty basic question…
> 
> Thank you guys…  
> the error message has all you need to get rid of this mistake.  
> “…for #\<Site…\>”

Now start irb and type something like:  
irb\> myarray = [1,2,3]  
irb\> newarray = myarray.each { |i| i \* 10 }  
irb\> p newarray  
do you see it?  
now try Array#map:  
irb\> myarray = [1,2,3]  
irb\> newarray = myarray.map { |i| i \* 10 }  
irb\> p newarray

see the difference?

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [January 14, 2009, 3:06pm UTC](https://www.ruby-forum.com/t/trying-to-parse-an-array-of-rss-feeds-without-success/157661/3 "2009-01-14T15:06:35Z")

</div>

badboy wrote:

> Louis-pierre Lp.dahito schrieb:
> 
> > def initialize  
> > b = Site.new  
> > require ‘rss/2.0’
> > 
> > method each in global.rb at line 38  
> > at top level in global.rb at line 38  
> > Program exited.
> > 
> > I need help even though it’s a pretty basic question…
> > 
> > Thank you guys…  
> > the error message has all you need to get rid of this mistake.  
> > “…for #\<Site…\>”
> 
> Now start irb and type something like:  
> irb\> myarray = [1,2,3]  
> irb\> newarray = myarray.each { |i| i \* 10 }  
> irb\> p newarray  
> do you see it?  
> now try Array#map:  
> irb\> myarray = [1,2,3]  
> irb\> newarray = myarray.map { |i| i \* 10 }  
> irb\> p newarray
> 
> see the difference?

I do see the difference… Thank a lot you fixed my problem… I thought  
that the each iterator would do the exact same thing the map method  
did…  
Anyway thank you very much for your time 🙂
