Loop and instance variable problem


#1

I have a loop for parsing each rss feed

@address.each do |address|
@feed = SimpleRSS.parse open(address.feed)
end

the problem is my my instance variable @feed just gets overwritten so
basically it displays the last parsed feed

how can i store each feed without it been overwrited so i can display it
in my view?

regards

nick


#2

On Tue, Apr 14, 2009 at 4:33 PM, Nick H.
removed_email_address@domain.invalid wrote:

how can i store each feed without it been overwrited so i can display it
in my view?

regards

nick

@feeds = []
@address.each do |address|
@feeds << SimpleRSS.parse open(address.feed)
end

In your view
@feeds.each do |fee|

end

Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

“I have never let my schooling interfere with my education” - Mark Twain


#3

Andrew T. wrote:

On Tue, Apr 14, 2009 at 4:33 PM, Nick H.
removed_email_address@domain.invalid wrote:

how can i store each feed without it been overwrited so i can display it
in my view?

regards

nick

@feeds = []
@address.each do |address|
@feeds << SimpleRSS.parse open(address.feed)
end

In your view
@feeds.each do |fee|

end

Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

“I have never let my schooling interfere with my education” - Mark Twain

Hi thanks for quick reply, i tried using << symbol before and it just
gave me a syntax error indicating theres somethings wrong around parse.
open


#4

On Apr 14, 2009, at 10:55 AM, Andrew T. wrote:

basically it displays the last parsed feed
@feeds = []
@address.each do |address|
@feeds << SimpleRSS.parse open(address.feed)
end

Or more simply:

@feeds = @address.map {|address| SimpleRSS.parse(open(address.feed)) }

“I have never let my schooling interfere with my education” - Mark
Twain

-Rob

Rob B. http://agileconsultingllc.com
removed_email_address@domain.invalid


#5

i just tried this with the built in rails rss parser and seems to work
fine. must be an issue with simple rss im guessing.