1
0
Fork 0
forked from OpenNeo/impress
impress/app/models/species.rb

21 lines
435 B
Ruby
Raw Normal View History

class Species
attr_accessor :id, :name
@objects = []
@objects_by_name = {}
File.open(Rails.root.join('config', 'species.txt')).each do |line|
name = line.chomp.downcase
@objects << @objects_by_name[name] = species = Species.new
species.id = @objects.size
species.name = name
end
def self.find(id)
@objects[id-1]
end
def self.find_by_name(name)
@objects_by_name[name.downcase]
end
end