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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f37eaa1b94b6fb0d31a7d65756b3c020d46e11cf
4
- data.tar.gz: 47327435fb477799e0edea1f61618237493164f3
3
+ metadata.gz: 00e24a7c5a09f6c9656266b33f520b97d25b14a7
4
+ data.tar.gz: 92bd0f1796745b134d2dcff1a8ae08373a04a6de
5
5
  SHA512:
6
- metadata.gz: bf13ab6669adf49a0ad29c80a9948f59f0e0ab01bdd0f0638f8bed7b48c83b0d74d33003479106a857139b2311452b69d6328957a2662d4f790a35fad8a01f58
7
- data.tar.gz: 9f65f21102d46cae68f37be9d6f95b297da379fdba017981a592149c36bcef761f01aee2d8c028c132b1e99cf05e815324830aa8ae518b0154676a14b36e6d66
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
- @id = get_integer(xml, "item", "id")
9
- @type = get_string(xml, "item", "type")
10
- @image = get_string(xml, "image")
11
- @thumbnail = get_string(xml, "thumbnail")
12
- @name = get_string(xml, "name[type='primary']", "value")
13
- @alternate_names = get_strings(xml, "name[type='alternate']", "value")
14
- @description = get_string(xml, "description")
15
- @year_published = get_integer(xml, "yearpublished", "value")
16
- @min_players = get_integer(xml, "minplayers", "value")
17
- @max_players = get_integer(xml, "maxplayers", "value")
18
- @playing_time = get_integer(xml, "playingtime", "value")
19
- @min_playing_time = get_integer(xml, "minplaytime", "value")
20
- @max_playing_time = get_integer(xml, "maxplaytime", "value")
21
- @statistics = nil
22
- if !xml.at_css("statistics").nil?
23
- @statistics = {}
24
- @statistics[:user_ratings] = get_integer(xml, "usersrated", "value")
25
- @statistics[:average] = get_float(xml, "average", "value")
26
- @statistics[:bayes] = get_float(xml, "bayesaverage", "value")
27
- @statistics[:ranks] = []
28
- xml.css("rank").each do |rank|
29
- rank_data = {}
30
- rank_data[:type] = rank["type"]
31
- rank_data[:name] = rank["name"]
32
- rank_data[:friendly_name] = rank["friendlyname"]
33
- rank_data[:value] = rank["value"].to_i
34
- rank_data[:bayes] = rank["bayesaverage"].to_f
35
- @statistics[:ranks].push(rank_data)
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
@@ -1,3 +1,3 @@
1
1
  module BoardGameGem
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: BoardGameGem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Roussel