BoardGameGem 0.1.6 → 0.1.7
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/bgg_item.rb +58 -37
- data/lib/boardgamegem/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: 00e24a7c5a09f6c9656266b33f520b97d25b14a7
|
4
|
+
data.tar.gz: 92bd0f1796745b134d2dcff1a8ae08373a04a6de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1b67cf6c449b6b176eb7b09a056b7f86d0afe2f9c12d482a6c9798b080986eea075e051d6517f30cfb50a4418c6848377aca29ae6d47938dcda5e6b67810d9b
|
7
|
+
data.tar.gz: 47e12f2dcb467ffdff5eef280f8a761c9987af72c837535eae486a20052f0fa809d4d9a0bf02f7ad015250a4b5000eba2161fc507c211f15e77d49c4463fa185
|
data/lib/bgg_item.rb
CHANGED
@@ -5,46 +5,67 @@ module BoardGameGem
|
|
5
5
|
:playing_time, :min_playing_time, :max_playing_time, :statistics
|
6
6
|
|
7
7
|
def initialize(xml)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
8
|
+
if !xml.nil?
|
9
|
+
@id = get_integer(xml, "item", "id")
|
10
|
+
@type = get_string(xml, "item", "type")
|
11
|
+
@image = get_string(xml, "image")
|
12
|
+
@thumbnail = get_string(xml, "thumbnail")
|
13
|
+
@name = get_string(xml, "name[type='primary']", "value")
|
14
|
+
@alternate_names = get_strings(xml, "name[type='alternate']", "value")
|
15
|
+
@description = get_string(xml, "description")
|
16
|
+
@year_published = get_integer(xml, "yearpublished", "value")
|
17
|
+
@min_players = get_integer(xml, "minplayers", "value")
|
18
|
+
@max_players = get_integer(xml, "maxplayers", "value")
|
19
|
+
@playing_time = get_integer(xml, "playingtime", "value")
|
20
|
+
@min_playing_time = get_integer(xml, "minplaytime", "value")
|
21
|
+
@max_playing_time = get_integer(xml, "maxplaytime", "value")
|
22
|
+
@statistics = nil
|
23
|
+
if !xml.at_css("statistics").nil?
|
24
|
+
@statistics = {}
|
25
|
+
@statistics[:user_ratings] = get_integer(xml, "usersrated", "value")
|
26
|
+
@statistics[:average] = get_float(xml, "average", "value")
|
27
|
+
@statistics[:bayes] = get_float(xml, "bayesaverage", "value")
|
28
|
+
@statistics[:ranks] = []
|
29
|
+
xml.css("rank").each do |rank|
|
30
|
+
rank_data = {}
|
31
|
+
rank_data[:type] = rank["type"]
|
32
|
+
rank_data[:name] = rank["name"]
|
33
|
+
rank_data[:friendly_name] = rank["friendlyname"]
|
34
|
+
rank_data[:value] = rank["value"].to_i
|
35
|
+
rank_data[:bayes] = rank["bayesaverage"].to_f
|
36
|
+
@statistics[:ranks].push(rank_data)
|
37
|
+
end
|
38
|
+
@statistics[:stddev] = get_float(xml, "stddev", "value")
|
39
|
+
@statistics[:median] = get_float(xml, "median", "value")
|
40
|
+
@statistics[:owned] = get_integer(xml, "owned", "value")
|
41
|
+
@statistics[:trading] = get_integer(xml, "trading", "value")
|
42
|
+
@statistics[:wanting] = get_integer(xml, "wanting", "value")
|
43
|
+
@statistics[:wishing] = get_integer(xml, "wishing", "value")
|
44
|
+
@statistics[:num_comments] = get_integer(xml, "numcomments", "value")
|
45
|
+
@statistics[:num_weights] = get_integer(xml, "numweights", "value")
|
46
|
+
@statistics[:average_weight] = get_integer(xml, "averageweight", "value")
|
47
|
+
else
|
48
|
+
@id = 0
|
49
|
+
@type = ""
|
50
|
+
@image = ""
|
51
|
+
@thumbnail = ""
|
52
|
+
@name = ""
|
53
|
+
@alternate_names = []
|
54
|
+
@description = ""
|
55
|
+
@year_published = -1
|
56
|
+
@min_players = -1
|
57
|
+
@max_players = -1
|
58
|
+
@playing_time = -1
|
59
|
+
@min_playing_time = -1
|
60
|
+
@max_playing_time = -1
|
61
|
+
@statistics = nil
|
36
62
|
end
|
37
|
-
@statistics[:stddev] = get_float(xml, "stddev", "value")
|
38
|
-
@statistics[:median] = get_float(xml, "median", "value")
|
39
|
-
@statistics[:owned] = get_integer(xml, "owned", "value")
|
40
|
-
@statistics[:trading] = get_integer(xml, "trading", "value")
|
41
|
-
@statistics[:wanting] = get_integer(xml, "wanting", "value")
|
42
|
-
@statistics[:wishing] = get_integer(xml, "wishing", "value")
|
43
|
-
@statistics[:num_comments] = get_integer(xml, "numcomments", "value")
|
44
|
-
@statistics[:num_weights] = get_integer(xml, "numweights", "value")
|
45
|
-
@statistics[:average_weight] = get_integer(xml, "averageweight", "value")
|
46
63
|
end
|
47
64
|
|
65
|
+
def self.blank
|
66
|
+
item = BGGItem.new(nil)
|
67
|
+
|
68
|
+
end
|
48
69
|
end
|
49
70
|
end
|
50
71
|
end
|
data/lib/boardgamegem/version.rb
CHANGED