Class: Type

Inherits:
PokeApi show all
Defined in:
lib/pokeruby/type.rb

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

#ineffectiveObject



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

def ineffective
	@ineffective ||= @type['ineffective'].collect { |type| create_type ty }
end

#nameObject



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

def name
	@type['name']
end

#no_effectObject



18
19
20
# File 'lib/pokeruby/type.rb', line 18

def no_effect
	@no_effect ||= @type['no_effect'].collect { |type| create_type type }
end

#resistanceObject



22
23
24
# File 'lib/pokeruby/type.rb', line 22

def resistance
	@resistance ||= @type['resistance'].collect { |type| create_type type }
end

#super_effectiveObject



26
27
28
# File 'lib/pokeruby/type.rb', line 26

def super_effective
	@super_effective ||= @type['super_effective'].collect { |type| create_type type }
end

#weaknessObject



30
31
32
# File 'lib/pokeruby/type.rb', line 30

def weakness
	@weakness ||= @type['weakness'].collect { |type| create_type type }
end