From eae1c764df31b5e5aa2a2d8315b2b5c0997babf4 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Oct 2017 23:09:37 -0400 Subject: Pokémon now show the Poké Ball that they're in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixed a bug with viewing Pokémon that aren't in any game. --- app/models/pokeviewer/pokemon.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/models') diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 18d1533..268a417 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb @@ -1,6 +1,7 @@ module Pokeviewer class Pokemon < ApplicationRecord extend Enumerize + extend ActiveModel::Naming belongs_to :species @@ -69,6 +70,10 @@ module Pokeviewer :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, :question, :exclamation] + validates :pokeball, presence: true + enumerize :pokeball, in: [:master, :ultra, :great, :poke, :safari, :net, + :dive, :nest, :repeat, :timer, :luxury, :premier] + def to_param uuid end @@ -191,6 +196,10 @@ module Pokeviewer end end + def pokeball_icon_path + "pokeviewer/items/#{Pokemon.pokeball.values.find_index(pokeball) + 1}.png" + end + private def set_uuid -- cgit 1.4.1