Hi. I have a number of classes that use a module as a mixin. Not sure if
I have my terms correct there. Anyway here is one of the classes......
require 'predicate'
class Song
include Pred
@@songs = [ ]
attr_accessor :name, :album, :artist, :time, :year, :id, :in_libs
def initialize(name, album, artist, time, id, in_libs)
 @name = name
 @album = album
 @time = time
 @artist = artist
 @id = id
 @in_libs = in_libs
end

def to_s
 puts "<< #{@name} >> by #{@artist} in their album #{@album}.\n"
end

def self.list
 @@songs
end

def self.list_add=(val)
 @@songs << val
end

end

.....................................

Here is the module....

module Pred
 def isa?(target_class)
  instance_of?(target_class)
 end
end

........................................
Here is another module that I  use to fetch data form classes such as
Song........

module Tuneuts
def self.fetch(item, out = [])
all = Song.list + Actor.list + Album.list + Library.list
case
when item.instance_of?(String)
all.each do |obj|

if obj.name.downcase == item.downcase
then out << obj end end
 if (out.length > 1)
  then MyErr.new("multiple_answer_error", item, "fetch").do_it end
 when item.isa?
  all.each {|obj|
if obj.eql?(item) then out << obj end}
else MyErr.new("weird_item", item, "fetch").do_it
 end
 out.first
end
end
............................


The problem is Song.list  (in the module Tuneuts)  is returning nothing.
Am I missing something here?

I've attached the whole program as a zip file FYI.

Thanks for taking a look

Attachments:
http://www.ruby-forum.com/attachment/5233/problem.zip


-- 
Posted via http://www.ruby-forum.com/.