forked from OpenNeo/impress
capitalize each word of a species/color name (for Swamp Gas)
This commit is contained in:
parent
dafc922fa5
commit
1caa296359
1 changed files with 10 additions and 9 deletions
|
@ -5,16 +5,16 @@ class PetAttribute < StaticResource
|
|||
:name => self.human_name
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
def human_name
|
||||
self.name.capitalize
|
||||
@human_name ||= self.name.split(' ').each { |word| word.capitalize! }.join(' ')
|
||||
end
|
||||
|
||||
|
||||
class << self
|
||||
def all_ordered_by_name
|
||||
@objects_ordered_by_name
|
||||
end
|
||||
|
||||
|
||||
def find(id)
|
||||
attribute = super
|
||||
unless attribute
|
||||
|
@ -24,25 +24,25 @@ class PetAttribute < StaticResource
|
|||
end
|
||||
attribute
|
||||
end
|
||||
|
||||
|
||||
def find_by_name(name)
|
||||
@objects_by_name[name.downcase]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def self.data_source
|
||||
"#{to_s.downcase.pluralize}.txt"
|
||||
end
|
||||
|
||||
|
||||
def self.process_line(line)
|
||||
name = line.chomp.downcase
|
||||
@objects << @objects_by_name[name] = species = new
|
||||
species.id = @objects.size
|
||||
species.name = name
|
||||
end
|
||||
|
||||
|
||||
def self.fetch_objects!
|
||||
@objects = []
|
||||
@objects_by_name = {}
|
||||
|
@ -52,3 +52,4 @@ class PetAttribute < StaticResource
|
|||
@objects_ordered_by_name = @objects.sort { |a,b| a.name <=> b.name }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue