capitalize each word of a species/color name (for Swamp Gas)

This commit is contained in:
Emi Matchu 2011-07-12 18:22:16 -04:00
parent dafc922fa5
commit 1caa296359

View file

@ -5,16 +5,16 @@ class PetAttribute < StaticResource
:name => self.human_name :name => self.human_name
} }
end end
def human_name def human_name
self.name.capitalize @human_name ||= self.name.split(' ').each { |word| word.capitalize! }.join(' ')
end end
class << self class << self
def all_ordered_by_name def all_ordered_by_name
@objects_ordered_by_name @objects_ordered_by_name
end end
def find(id) def find(id)
attribute = super attribute = super
unless attribute unless attribute
@ -24,25 +24,25 @@ class PetAttribute < StaticResource
end end
attribute attribute
end end
def find_by_name(name) def find_by_name(name)
@objects_by_name[name.downcase] @objects_by_name[name.downcase]
end end
end end
private private
def self.data_source def self.data_source
"#{to_s.downcase.pluralize}.txt" "#{to_s.downcase.pluralize}.txt"
end end
def self.process_line(line) def self.process_line(line)
name = line.chomp.downcase name = line.chomp.downcase
@objects << @objects_by_name[name] = species = new @objects << @objects_by_name[name] = species = new
species.id = @objects.size species.id = @objects.size
species.name = name species.name = name
end end
def self.fetch_objects! def self.fetch_objects!
@objects = [] @objects = []
@objects_by_name = {} @objects_by_name = {}
@ -52,3 +52,4 @@ class PetAttribute < StaticResource
@objects_ordered_by_name = @objects.sort { |a,b| a.name <=> b.name } @objects_ordered_by_name = @objects.sort { |a,b| a.name <=> b.name }
end end
end end