class Pokemon
Attributes
name[R]
type[R]
Public Class Methods
all()
click to toggle source
# File lib/pokemon.rb, line 21 def self.all @@all end
find_or_create_by_name(name)
click to toggle source
# File lib/pokemon.rb, line 25 def self.find_or_create_by_name(name) if Scraper.pokemons.include?(name) return self.all.detect{|a| a.name == name} if self.all.collect{|a| a.name}.include?(name) return Pokemon.new(name) end return nil end
new(name)
click to toggle source
# File lib/pokemon.rb, line 7 def initialize(name) @name = name @type = Scraper.get_pokemon_by_name(name)["types"][0]["type"]["name"] @@all << self end
Public Instance Methods
can_learn_move?(move)
click to toggle source
# File lib/pokemon.rb, line 17 def can_learn_move?(move) self.get_moves.collect{|m| m.name}.include?(move.name) end
get_moves()
click to toggle source
# File lib/pokemon.rb, line 13 def get_moves Scraper.get_pokemon_by_name(@name)["moves"].collect{|move_hash| Move.new(move_hash["move"]["name"])} end