2010-05-16 12:01:38 -07:00
|
|
|
require 'yaml'
|
|
|
|
|
2010-05-15 08:38:45 -07:00
|
|
|
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
|
|
|
|
|
2010-05-16 12:01:38 -07:00
|
|
|
StandardColors = %w(blue green yellow red)
|
|
|
|
StandardHashes = YAML::load_file(Rails.root.join('config', 'standard_type_hashes.yml'))
|
|
|
|
|
|
|
|
def hash_for_color(color)
|
|
|
|
StandardHashes[name][color]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.all
|
|
|
|
@objects
|
|
|
|
end
|
|
|
|
|
2010-05-15 08:38:45 -07:00
|
|
|
def self.find(id)
|
|
|
|
@objects[id-1]
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.find_by_name(name)
|
|
|
|
@objects_by_name[name.downcase]
|
|
|
|
end
|
|
|
|
end
|