OK, hate to multi-post, but wanted to let you know that i made it, is ot really elegant, i wish there was a better way to do it, but at least 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 olumns but multiple columns? (i was thinking of creating a array with he values and then using 2 for loops to retrieve each value, but that ould have been really stupid i believe).