about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-10-04 23:09:37 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-10-04 23:09:37 -0400
commiteae1c764df31b5e5aa2a2d8315b2b5c0997babf4 (patch)
tree412387cc73d166c28fa4e0f5658bded6d4b7fbc8 /app/models
parent52bac73894ad0fe20d7aec907bbd7f07e83ca477 (diff)
downloadpokeviewer-eae1c764df31b5e5aa2a2d8315b2b5c0997babf4.tar.gz
pokeviewer-eae1c764df31b5e5aa2a2d8315b2b5c0997babf4.tar.bz2
pokeviewer-eae1c764df31b5e5aa2a2d8315b2b5c0997babf4.zip
Pokémon now show the Poké Ball that they're in
Also fixed a bug with viewing Pokémon that aren't in any game.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/pokeviewer/pokemon.rb9
1 files changed, 9 insertions, 0 deletions
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 @@
1module Pokeviewer 1module Pokeviewer
2 class Pokemon < ApplicationRecord 2 class Pokemon < ApplicationRecord
3 extend Enumerize 3 extend Enumerize
4 extend ActiveModel::Naming
4 5
5 belongs_to :species 6 belongs_to :species
6 7
@@ -69,6 +70,10 @@ module Pokeviewer
69 :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, 70 :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z,
70 :question, :exclamation] 71 :question, :exclamation]
71 72
73 validates :pokeball, presence: true
74 enumerize :pokeball, in: [:master, :ultra, :great, :poke, :safari, :net,
75 :dive, :nest, :repeat, :timer, :luxury, :premier]
76
72 def to_param 77 def to_param
73 uuid 78 uuid
74 end 79 end
@@ -191,6 +196,10 @@ module Pokeviewer
191 end 196 end
192 end 197 end
193 198
199 def pokeball_icon_path
200 "pokeviewer/items/#{Pokemon.pokeball.values.find_index(pokeball) + 1}.png"
201 end
202
194 private 203 private
195 204
196 def set_uuid 205 def set_uuid