Sha256: a2807cb9f947e783645b7cf9085ec846360f890f3d8bfecac0ea8f62f0a4a7a2
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
class Ability extend Findable attr_accessor :name, :id, :effect, :pokemon_with_ability, :url, :data @@all = [] @@tag = "ability" @@limit = 293 def initialize(name, url) self.name = name self.url = url self.data = JSON.parse(RestClient.get(url)) self.pokemon_with_ability = [] self.set_attributes @@all << self end def self.all @@all end def self.tag @@tag end def tag @@tag end def self.limit @@limit end def set_attributes self.set_effect self.set_id end def set_effect effect_entries = self.data["effect_entries"] effect_entries.each do |entry| if entry["language"]["name"] == "en" self.effect = entry["effect"] end end end def set_id self.id = self.data["id"] end def add_pokemon(pokemon) self.pokemon_with_ability << pokemon end def print_all puts "---------------------------------------------------------" puts " Dexter++ : Ability ".light_blue puts "---------------------------------------------------------" self.print_name puts "" self.print_effect puts "---------------------------------------------------------" end def self.print_all @@all.each {|ability| ability.print_all} end def print_name puts "Name: #{self.name.capitalize.light_blue}" end def get_colored_name self.name.capitalize.light_blue end def print_effect puts "Effect: #{self.effect}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dexter_plusplus-0.2.0 | lib/dexter_plusplus/ability.rb |