Class: Type
Instance Method Summary
collapse
Methods inherited from PokeApi
get, get_resource, type_chart
Constructor Details
#initialize(id) ⇒ Type
Returns a new instance of Type.
5
6
7
8
|
# File 'lib/pokeruby/type.rb', line 5
def initialize id
@type = self.class.get "#{id}"
self.class.type_chart[self.name] ||= self
end
|
Instance Method Details
#create_type(type) ⇒ Object
34
35
36
|
# File 'lib/pokeruby/type.rb', line 34
def create_type type
self.class.type_chart[type['name'].capitalize] ||= Type.new type['resource_uri']
end
|
#ineffective ⇒ Object
14
15
16
|
# File 'lib/pokeruby/type.rb', line 14
def ineffective
@ineffective ||= @type['ineffective'].collect { |type| create_type ty }
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/pokeruby/type.rb', line 10
def name
@type['name']
end
|
#no_effect ⇒ Object
18
19
20
|
# File 'lib/pokeruby/type.rb', line 18
def no_effect
@no_effect ||= @type['no_effect'].collect { |type| create_type type }
end
|
#resistance ⇒ Object
22
23
24
|
# File 'lib/pokeruby/type.rb', line 22
def resistance
@resistance ||= @type['resistance'].collect { |type| create_type type }
end
|
#super_effective ⇒ Object
26
27
28
|
# File 'lib/pokeruby/type.rb', line 26
def super_effective
@super_effective ||= @type['super_effective'].collect { |type| create_type type }
end
|
#weakness ⇒ Object
30
31
32
|
# File 'lib/pokeruby/type.rb', line 30
def weakness
@weakness ||= @type['weakness'].collect { |type| create_type type }
end
|