From: "Andres M." Date: 2011-12-04T12:05:30+09:00 Subject: Re: Dynamic instances of a class. OK, hate to multi-post, but wanted to let you know that i made it, is not really elegant, i wish there was a better way to do it, but at least i (kind of) get a solution for the main problem on this post. Here is the code. require 'csv' class Motorcycle attr_reader :name, :weight @@count = 0 def self.find (name) found = nil ObjectSpace.each_object(Motorcycle) { |o| found = o if o.name == name } return found end #Dynamically create instances of Motrocycle def self.create File.new('motorcycles.csv').readlines[1..-1].map{ |line| first, *rest = line.split(/,/) Motorcycle.new( first, rest ) } end def initialize (name, weight) @name = name @weight = weight self.class.count += 1 end def self.count return @@count end def self.count=( count ) @@count = count end def available_colors end def has_abs? end end Is there any way to do it better, like, ¿ what is i didn't have 2 columns but multiple columns? (i was thinking of creating a array with the values and then using 2 for loops to retrieve each value, but that would have been really stupid i believe). -- Posted via http://www.ruby-forum.com/.