class Type

Attributes

damage_relations[RW]
data[RW]
id[RW]
moves[RW]
name[RW]
pokemon_with_type[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/dexter_plusplus/type.rb, line 25
def self.all
    @@all
end
limit() click to toggle source
# File lib/dexter_plusplus/type.rb, line 33
def self.limit
    @@limit
end
new(name, url) click to toggle source
# File lib/dexter_plusplus/type.rb, line 9
def initialize(name, url)
    self.name = name
    self.url = url
    self.data = JSON.parse(RestClient.get(url))
    self.moves = []
    self.pokemon_with_type = []
    self.damage_relations = {}
    self.set_attributes
    @@all << self
end
print_all() click to toggle source
tag() click to toggle source
# File lib/dexter_plusplus/type.rb, line 29
def self.tag
    @@tag
end

Public Instance Methods

add_move(move) click to toggle source
# File lib/dexter_plusplus/type.rb, line 45
def add_move(move)
    if !self.moves.include?(move)
        self.moves << move
    end
end
add_pokemon(pokemon) click to toggle source
# File lib/dexter_plusplus/type.rb, line 41
def add_pokemon(pokemon)
   self.pokemon_with_type << pokemon
end
get_double_damage_from() click to toggle source
# File lib/dexter_plusplus/type.rb, line 67
def get_double_damage_from
    output = []
    types = self.data["damage_relations"]["double_damage_from"]
    types.each{|type| output << type["name"]}
    output 
end
get_double_damage_to() click to toggle source
# File lib/dexter_plusplus/type.rb, line 60
def get_double_damage_to
    output = []
    types = self.data["damage_relations"]["double_damage_to"]
    types.each{|type| output << type["name"]}
    output 
end
get_half_damage_from() click to toggle source
# File lib/dexter_plusplus/type.rb, line 81
def get_half_damage_from
    output = []
    types = self.data["damage_relations"]["half_damage_from"]
    types.each{|type| output << type["name"]}
    output 
end
get_half_damage_to() click to toggle source
# File lib/dexter_plusplus/type.rb, line 74
def get_half_damage_to
    output = []
    types = self.data["damage_relations"]["half_damage_to"]
    types.each{|type| output << type["name"]}
    output 
end
get_no_damage_from() click to toggle source
# File lib/dexter_plusplus/type.rb, line 95
def get_no_damage_from
    output = []
    types = self.data["damage_relations"]["no_damage_from"]
    types.each{|type| output << type["name"]}
    output 
end
get_no_damage_to() click to toggle source
# File lib/dexter_plusplus/type.rb, line 88
def get_no_damage_to
    output = []
    types = self.data["damage_relations"]["no_damage_to"]
    types.each{|type| output << type["name"]}
    output 
end
print_all() click to toggle source
print_damage_relations() click to toggle source
print_name(name) click to toggle source
set_attributes() click to toggle source
# File lib/dexter_plusplus/type.rb, line 20
def set_attributes
    self.id = self.data["id"]
    self.set_damage_relations
end
set_damage_relations() click to toggle source
# File lib/dexter_plusplus/type.rb, line 51
def set_damage_relations
   self.damage_relations["double_damage_to"] = self.get_double_damage_to
   self.damage_relations["double_damage_from"] = self.get_double_damage_from
   self.damage_relations["half_damage_to"] = self.get_half_damage_to
   self.damage_relations["half_damage_from"] = self.get_half_damage_from
   self.damage_relations["no_damage_to"] = self.get_no_damage_to
   self.damage_relations["no_damage_from"] = self.get_no_damage_from
end
tag() click to toggle source
# File lib/dexter_plusplus/type.rb, line 37
def tag
    @@tag
end