wowget 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/wowget/item.rb +22 -22
  2. data/spec/item_spec.rb +4 -4
  3. metadata +1 -1
data/lib/wowget/item.rb CHANGED
@@ -10,8 +10,8 @@ module Wowget
10
10
  attr_accessor :name
11
11
  attr_accessor :level
12
12
  attr_accessor :quality_id
13
- attr_accessor :item_class_id
14
- attr_accessor :item_subclass_id
13
+ attr_accessor :category_id
14
+ attr_accessor :subcategory_id
15
15
  attr_accessor :icon_id
16
16
  attr_accessor :icon_name
17
17
  attr_accessor :required_level
@@ -22,7 +22,7 @@ module Wowget
22
22
  attr_accessor :error
23
23
 
24
24
  ITEM_QUALITIES = ['Poor', 'Common', 'Uncommon', 'Rare', 'Epic', 'Legendary', 'Artifact', 'Heirloom']
25
- ITEM_CLASSES = {
25
+ ITEM_CATEGORIES = {
26
26
  0 => 'Consumables',
27
27
  1 => 'Containers',
28
28
  2 => 'Weapons',
@@ -36,7 +36,7 @@ module Wowget
36
36
  15 => 'Miscellaneous',
37
37
  16 => 'Glyphs'
38
38
  }
39
- ITEM_SUBCLASSES = {
39
+ ITEM_SUBCATEGORIES = {
40
40
  'Consumables' => {
41
41
  0 => 'Consumables',
42
42
  1 => 'Potions',
@@ -211,20 +211,20 @@ module Wowget
211
211
  if item_xml.css('wowhead error').length == 1
212
212
  self.error = {:error => "not found"}
213
213
  else
214
- item_json = JSON "{#{item_xml.css('wowhead item json').inner_text.strip.to_s}}"
215
- item_equip_json = JSON "{#{item_xml.css('wowhead item jsonEquip').inner_text.strip.to_s}}"
216
- self.id = item_id.to_i
217
- self.name = item_xml.css('wowhead item name').inner_text.strip.to_s
218
- self.level = item_xml.css('wowhead item level').inner_text.strip.to_i
219
- self.quality_id = item_xml.css('wowhead item quality').attribute('id').content.to_i
220
- self.item_class_id = item_xml.css('wowhead item class').attribute('id').content.to_i
221
- self.item_subclass_id = item_xml.css('wowhead item subclass').attribute('id').content.to_i
222
- self.icon_id = item_xml.css('wowhead item icon').attribute('displayId').content.to_i
223
- self.icon_name = item_xml.css('wowhead item icon').inner_text.strip.to_s
224
- self.required_level = item_json['reqlevel']
225
- self.inventory_slot_id = item_xml.css('wowhead item inventorySlot').attribute('id').content.to_i
226
- self.buy_price = item_equip_json['buyprice'].to_f / 10000
227
- self.sell_price = item_equip_json['sellprice'].to_f / 10000
214
+ item_json = JSON "{#{item_xml.css('wowhead item json').inner_text.strip.to_s}}"
215
+ item_equip_json = JSON "{#{item_xml.css('wowhead item jsonEquip').inner_text.strip.to_s}}"
216
+ self.id = item_id.to_i
217
+ self.name = item_xml.css('wowhead item name').inner_text.strip.to_s
218
+ self.level = item_xml.css('wowhead item level').inner_text.strip.to_i
219
+ self.quality_id = item_xml.css('wowhead item quality').attribute('id').content.to_i
220
+ self.category_id = item_xml.css('wowhead item class').attribute('id').content.to_i
221
+ self.subcategory_id = item_xml.css('wowhead item subclass').attribute('id').content.to_i
222
+ self.icon_id = item_xml.css('wowhead item icon').attribute('displayId').content.to_i
223
+ self.icon_name = item_xml.css('wowhead item icon').inner_text.strip.to_s
224
+ self.required_level = item_json['reqlevel']
225
+ self.inventory_slot_id = item_xml.css('wowhead item inventorySlot').attribute('id').content.to_i
226
+ self.buy_price = item_equip_json['buyprice'].to_f / 10000
227
+ self.sell_price = item_equip_json['sellprice'].to_f / 10000
228
228
 
229
229
  if item_xml.css('wowhead item createdBy').length == 1
230
230
  self.recipe_id = item_xml.css('wowhead item createdBy spell').attribute('id').content.to_i
@@ -241,12 +241,12 @@ module Wowget
241
241
  ITEM_QUALITIES[self.quality_id]
242
242
  end
243
243
 
244
- def item_class
245
- ITEM_CLASSES[self.item_class_id]
244
+ def category
245
+ ITEM_CATEGORIES[self.category_id]
246
246
  end
247
247
 
248
- def item_subclass
249
- ITEM_SUBCLASSES[self.item_class][self.item_subclass_id]
248
+ def subcategory
249
+ ITEM_SUBCATEGORIES[self.category][self.subcategory_id]
250
250
  end
251
251
 
252
252
  def inventory_slot
data/spec/item_spec.rb CHANGED
@@ -22,19 +22,19 @@ describe Wowget::Item do
22
22
  end
23
23
 
24
24
  it "should have an item class value" do
25
- item.item_class_id.should == 2
25
+ item.category_id.should == 2
26
26
  end
27
27
 
28
28
  it "should have an item class name" do
29
- item.item_class.should == "Weapons"
29
+ item.category.should == "Weapons"
30
30
  end
31
31
 
32
32
  it "should have an item subclass value" do
33
- item.item_subclass_id.should == 8
33
+ item.subcategory_id.should == 8
34
34
  end
35
35
 
36
36
  it "should have an item subclass name" do
37
- item.item_subclass.should == "Two-Handed Swords"
37
+ item.subcategory.should == "Two-Handed Swords"
38
38
  end
39
39
 
40
40
  it "should have an icon value" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wowget
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.8
5
+ version: 0.1.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Darlow