On 10/22/2010 03:10 PM, Paul Roche wrote:
> Hi. I'm bumping this question again with a simpler twist........
> 
> I have these methods......
> 
> def self.list
>  @@songs
> end
> 
> def self.list_add=(val)
>  @@songs << val
> end
> 
> in song.rb
> 
> -----------------------
> 
> I can successfully fetch in the 'songs'through a CSV file.
> 
> I am able to populate an array like this.....
> 
> songx = ObjectSpace.each_object(Song).to_a
> 
> 
> I want to do the same thing using Song.list_add

Your current list_add implementation is designed to allow you to add one
Song instance at a time to the list.  It's not clear what you really
want to do here.  Maybe what you want to do instead is remove your
list_add method entirely and then have your list method simply return
the list generated from ObjectSpace:

def self.list
  ObjectSpace.each_object(Song).to_a
end

With that in place, you wouldn't need to have the list_add method
anymore.  Of course a much better solution is to have whatever you're
using to load your CSV information call list_add for each Sing instance
it creates.

BTW, I downloaded your code earlier and tried to take a look at it.
Aside from the fact that you really need to pick an indenting convention
and stick to it (it will make your code *much* easier for others to
read), I'm struck my your use of class variables all over the place.
Why are you doing that, or more generally, what are you trying to
accomplish overall?

-Jeremy