Class: Pokemongodb::Type

Inherits:
Pokemongodb show all
Defined in:
lib/pokemongodb/type.rb,
lib/pokemongodb/types/bug.rb,
lib/pokemongodb/types/ice.rb,
lib/pokemongodb/types/dark.rb,
lib/pokemongodb/types/fire.rb,
lib/pokemongodb/types/rock.rb,
lib/pokemongodb/types/fairy.rb,
lib/pokemongodb/types/ghost.rb,
lib/pokemongodb/types/grass.rb,
lib/pokemongodb/types/steel.rb,
lib/pokemongodb/types/water.rb,
lib/pokemongodb/types/dragon.rb,
lib/pokemongodb/types/flying.rb,
lib/pokemongodb/types/ground.rb,
lib/pokemongodb/types/normal.rb,
lib/pokemongodb/types/poison.rb,
lib/pokemongodb/types/psychic.rb,
lib/pokemongodb/types/electric.rb,
lib/pokemongodb/types/fighting.rb

Defined Under Namespace

Classes: Bug, Dark, Dragon, Electric, Fairy, Fighting, Fire, Flying, Ghost, Grass, Ground, Ice, Normal, Poison, Psychic, Rock, Steel, Water

Class Method Summary collapse

Methods inherited from Pokemongodb

to_s

Class Method Details

.allObject

Returns array of all available Types.

Example:

>> Pokemongodb::Type.all
=> [Pokemongodb::Type::Bug, ..., Pokemongodb::Type::Water]


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pokemongodb/type.rb', line 9

def self.all
  [
    Type::Bug,
    Type::Dark,
    Type::Dragon,
    Type::Electric,
    Type::Fairy,
    Type::Fighting,
    Type::Fire,
    Type::Flying,
    Type::Ghost,
    Type::Grass,
    Type::Ground,
    Type::Ice,
    Type::Normal,
    Type::Poison,
    Type::Psychic,
    Type::Rock,
    Type::Steel,
    Type::Water
  ]
end

.locationsObject

Returns array of locations where type spawns

Example:

>> Pokemongodb::Type::Normal.locations
=> [Pokemongodb::Location::CollegeCampus, Pokemongodb::Location::ParkingLot, ...]


37
38
39
40
41
# File 'lib/pokemongodb/type.rb', line 37

def self.locations
  Pokemongodb::Location.all.select do |location|
    location.types.include?(self)
  end
end

.strong_againstObject

Returns array of types where both the offense and defense are strong.

Example:

>> Pokemongodb::Type::Steel.strong_against
=> [Pokemongodb::Type::Fairy, Pokemongodb::Type::Ice, Pokemongodb::Type::Rock]


48
49
50
# File 'lib/pokemongodb/type.rb', line 48

def self.strong_against
  self.offense_strong & self.defense_strong
end

.weak_againstObject

Returns array of types where both the offense and defense are weak.

Example:

>> Pokemongodb::Type::Grass.weak_against
=> [Pokemongodb::Type::Bug, Pokemongodb::Type::Fire, Pokemongodb::Type::Flying, Pokemongodb::Type::Poison]


57
58
59
# File 'lib/pokemongodb/type.rb', line 57

def self.weak_against
  self.offense_weak & self.defense_weak
end