2010-05-15 10:47:46 -07:00
|
|
|
module ItemsHelper
|
2010-05-16 12:01:38 -07:00
|
|
|
StandardSpeciesImageFormat = 'http://pets.neopets.com/cp/%s/1/1.png'
|
|
|
|
|
2010-05-16 13:15:21 -07:00
|
|
|
def standard_species_images(species_list)
|
|
|
|
colors = Color::Basic
|
|
|
|
pet_type = PetType.new
|
|
|
|
raw(species_list.inject('') do |html, species|
|
2010-05-16 12:01:38 -07:00
|
|
|
color = colors[rand(colors.size)]
|
2010-05-16 13:15:21 -07:00
|
|
|
pet_type.species = species
|
|
|
|
pet_type.color = color
|
|
|
|
src = sprintf(StandardSpeciesImageFormat, pet_type.image_hash)
|
2010-05-16 16:21:36 -07:00
|
|
|
human_name = species.name.humanize
|
|
|
|
image = image_tag(src, :alt => human_name, :title => human_name)
|
2010-05-31 12:45:03 -07:00
|
|
|
html + link_to(
|
|
|
|
image,
|
|
|
|
'#',
|
|
|
|
'data-color-id' => color.id,
|
|
|
|
'data-color-name' => color.name,
|
|
|
|
'data-species-id' => species.id,
|
|
|
|
'data-species-name' => species.name
|
|
|
|
)
|
2010-05-16 12:01:38 -07:00
|
|
|
end)
|
|
|
|
end
|
2010-05-15 10:47:46 -07:00
|
|
|
end
|