battle_pet 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/battle_pet.rb +9 -1
  2. data/lib/pet_ability.rb +11 -0
  3. metadata +2 -1
data/lib/battle_pet.rb CHANGED
@@ -3,9 +3,10 @@ require 'json'
3
3
  require 'yaml'
4
4
 
5
5
  require_relative 'pet_type.rb'
6
+ require_relative 'pet_ability.rb'
6
7
 
7
8
  class BattlePet
8
- attr_accessor :id, :name, :description, :source, :type, :creature
9
+ attr_accessor :id, :name, :description, :source, :type, :creature, :abilities
9
10
 
10
11
  REGION_HOSTS = { us: 'us.battle.net',
11
12
  eu: 'eu.battle.net',
@@ -25,6 +26,7 @@ class BattlePet
25
26
  @can_battle = info["canBattle"]
26
27
  @type = PetType.find info["petTypeId"]
27
28
  @creature = info["creatureId"]
29
+ @abilities = acquire_abilities info["abilities"]
28
30
  end
29
31
 
30
32
  def can_battle?
@@ -40,4 +42,10 @@ class BattlePet
40
42
  def find_name(locale)
41
43
  PET_NAMES[id] && PET_NAMES[id]["name"][locale.to_s]
42
44
  end
45
+
46
+ def acquire_abilities(abilities)
47
+ results = {}
48
+ abilities.each { |ability| results[ability['requiredLevel']] = PetAbility.new(ability) }
49
+ results
50
+ end
43
51
  end
@@ -0,0 +1,11 @@
1
+ class PetAbility
2
+ attr_accessor :id, :name, :type, :cooldown, :rounds
3
+
4
+ def initialize(params)
5
+ @id = params["id"]
6
+ @name = params["name"]
7
+ @type = PetType.find(params["petTypeId"])
8
+ @cooldown = params["cooldown"]
9
+ @rounds = params["rounds"]
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: battle_pet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - lib/battle_pet.rb
21
21
  - lib/battle_pet.yml
22
+ - lib/pet_ability.rb
22
23
  - lib/pet_type.rb
23
24
  - README.md
24
25
  homepage: https://github.com/hegwin/battle_pet