Class: PokeAPI::Type

Inherits:
Base
  • Object
show all
Defined in:
lib/pokeapi/type.rb

Constant Summary collapse

TYPES =
%w(normal fighting flying poison ground rock bug ghost steel fire water grass electric psychic ice dragon dark fairy).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(id) ⇒ Object



14
15
16
17
# File 'lib/pokeapi/type.rb', line 14

def find(id)
  response = Requester.type(id)
  new response
end

.valid?(type) ⇒ Boolean



10
11
12
# File 'lib/pokeapi/type.rb', line 10

def valid?(type)
  TYPES.include?(type.to_s.downcase)
end

Instance Method Details

#reloadObject



20
21
22
23
24
# File 'lib/pokeapi/type.rb', line 20

def reload
  response = Requester.type(id)
  update_attributes!(response)
  self
end