battle_pet 0.1.0 → 0.1.1

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 +3 -16
  2. data/lib/pet_type.rb +16 -0
  3. metadata +4 -3
data/lib/battle_pet.rb CHANGED
@@ -2,6 +2,8 @@ require 'open-uri'
2
2
  require 'json'
3
3
  require 'yaml'
4
4
 
5
+ require_relative 'pet_type.rb'
6
+
5
7
  class BattlePet
6
8
  attr_accessor :id, :name, :description, :source, :type, :creature
7
9
 
@@ -12,17 +14,6 @@ class BattlePet
12
14
  cn: 'www.battlenet.com.cn'}
13
15
 
14
16
  PET_NAMES = YAML.load File.read(File.join(File.dirname(__FILE__), 'battle_pet.yml'))
15
-
16
- PET_TYPES = { 0 => 'Humanoid',
17
- 1 => 'Dragonkin',
18
- 2 => 'Flying',
19
- 3 => 'Undead',
20
- 4 => 'Critter',
21
- 5 => 'Magical',
22
- 6 => 'Elemental',
23
- 7 => 'Beast',
24
- 8 => 'Aquatic',
25
- 9 => 'Mechanical' }
26
17
 
27
18
  def initialize(id, locale = :us)
28
19
  url = "http://#{host(locale)}/api/wow/battlePet/species/#{id.to_s}"
@@ -32,7 +23,7 @@ class BattlePet
32
23
  @name = find_name(locale)
33
24
  @source = info["source"]
34
25
  @can_battle = info["canBattle"]
35
- @type = pet_type info["petTypeId"]
26
+ @type = PetType.find info["petTypeId"]
36
27
  @creature = info["creatureId"]
37
28
  end
38
29
 
@@ -49,8 +40,4 @@ class BattlePet
49
40
  def find_name(locale)
50
41
  PET_NAMES[id] && PET_NAMES[id]["name"][locale.to_s]
51
42
  end
52
-
53
- def pet_type(type_id)
54
- PET_TYPES[type_id]
55
- end
56
43
  end
data/lib/pet_type.rb ADDED
@@ -0,0 +1,16 @@
1
+ class PetType
2
+ PET_TYPES = { 0 => 'Humanoid',
3
+ 1 => 'Dragonkin',
4
+ 2 => 'Flying',
5
+ 3 => 'Undead',
6
+ 4 => 'Critter',
7
+ 5 => 'Magical',
8
+ 6 => 'Elemental',
9
+ 7 => 'Beast',
10
+ 8 => 'Aquatic',
11
+ 9 => 'Mechanical' }
12
+
13
+ def self.find(type_id)
14
+ PET_TYPES[type_id]
15
+ end
16
+ 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.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-10 00:00:00.000000000 Z
12
+ date: 2013-05-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple gem to get data from WoW BattlePet API
15
15
  email: zwt315@163.com
@@ -19,8 +19,9 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - lib/battle_pet.rb
21
21
  - lib/battle_pet.yml
22
+ - lib/pet_type.rb
22
23
  - README.md
23
- homepage: http://rubygems.org
24
+ homepage: https://github.com/hegwin/battle_pet
24
25
  licenses: []
25
26
  post_install_message:
26
27
  rdoc_options: []