hearthstone_api_utils 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ed7f5db3848aff7630d96b9a85a384289fc371b
4
- data.tar.gz: caddd5f47dd38aaa535dad2f2beb88b07e4fca15
3
+ metadata.gz: d61295730a2b0afbb33ac8ccde6de43a495b9454
4
+ data.tar.gz: 5bb7a4d76667b9b551f876292d5d8a5fe0de1870
5
5
  SHA512:
6
- metadata.gz: 93f18ac1327304c45ed79e6d8e87d78b05e4b34daad0a669b371b60b58e4e1d7aeaffe13e7654d23feedf92064982333154ed77d3bd6d27f9f46ba20a0f48857
7
- data.tar.gz: f3a4080ecedbc397068d8c8eca6798cf08dae6d78b8f4f4fb1836e1fa9095da631ae4eec8a4ae25da0f7049d1f07e636597bc04ec5086f23fdfeba3ee8245519
6
+ metadata.gz: 619e3bf9ad0965c3ef6ae4e4813bab5d50ebc748adafcf352584d1fe045c4ab2618365d8f98e301b80bf102114b0e1f2ae4e5c7d1206b4452ab3e20d1c6b758d
7
+ data.tar.gz: 10c8c7ecd0a5bbb17aa7c49f872d971b63b982f508c8a61deaba1302133b11ec3450803604f8eafbf08b392d06049bbfec06e24355c80927a64a372e63c17340
@@ -31,6 +31,7 @@ class HearthstoneAPI::CardParser
31
31
 
32
32
  parsed_cards.each do |card|
33
33
  add_image_url card
34
+ add_stats card # useful for text searching
34
35
  remove_unwanted_attributes card, 'createdAt', 'updatedAt', 'id'
35
36
  restore_type_value card
36
37
  restore_class_value card
@@ -59,6 +60,14 @@ class HearthstoneAPI::CardParser
59
60
  card["image_url"] = card_image_base_url << formatted_card_name << '.png'
60
61
  end
61
62
 
63
+ def add_stats card
64
+ health, attack = card['health'], card['attack']
65
+
66
+ if health and attack
67
+ card['stats'] = "#{health}/#{attack}"
68
+ end
69
+ end
70
+
62
71
  def remove_unwanted_attributes card, *attrs
63
72
  attrs.each { |attr| card.delete attr }
64
73
  end
@@ -80,17 +89,17 @@ class HearthstoneAPI::CardParser
80
89
 
81
90
  def restore_class_value card
82
91
  case card['classs']
83
- when 1 then card['class'] = 'Warrior'
84
- when 2 then card['class'] = 'Paladin'
85
- when 3 then card['class'] = 'Hunter'
86
- when 4 then card['class'] = 'Rogue'
87
- when 5 then card['class'] = 'Priest'
88
- when 7 then card['class'] = 'Shaman'
89
- when 8 then card['class'] = 'Mage'
90
- when 9 then card['class'] = 'Warlock'
91
- when 11 then card['class'] = 'Druid'
92
+ when 1 then card['classs'] = 'Warrior'
93
+ when 2 then card['classs'] = 'Paladin'
94
+ when 3 then card['classs'] = 'Hunter'
95
+ when 4 then card['classs'] = 'Rogue'
96
+ when 5 then card['classs'] = 'Priest'
97
+ when 7 then card['classs'] = 'Shaman'
98
+ when 8 then card['classs'] = 'Mage'
99
+ when 9 then card['classs'] = 'Warlock'
100
+ when 11 then card['classs'] = 'Druid'
92
101
  else
93
- card['class'] = 'Neutral'
102
+ card['classs'] = 'Neutral'
94
103
  end
95
104
 
96
105
  card.delete 'classs'
@@ -1,3 +1,3 @@
1
1
  module HearthstoneApiUtils
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hearthstone_api_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Vanadio