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



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

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

.valid?(type) ⇒ Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#reloadObject



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

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