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 +4 -4
- data/lib/hearthstone_api_utils.rb +19 -10
- data/lib/hearthstone_api_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d61295730a2b0afbb33ac8ccde6de43a495b9454
|
4
|
+
data.tar.gz: 5bb7a4d76667b9b551f876292d5d8a5fe0de1870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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['
|
84
|
-
when 2 then card['
|
85
|
-
when 3 then card['
|
86
|
-
when 4 then card['
|
87
|
-
when 5 then card['
|
88
|
-
when 7 then card['
|
89
|
-
when 8 then card['
|
90
|
-
when 9 then card['
|
91
|
-
when 11 then card['
|
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['
|
102
|
+
card['classs'] = 'Neutral'
|
94
103
|
end
|
95
104
|
|
96
105
|
card.delete 'classs'
|