Module: BoardGameGem
- Defined in:
- lib/bgg_base.rb,
lib/bgg_item.rb,
lib/bgg_user.rb,
lib/bgg_family.rb,
lib/bgg_collection.rb,
lib/board-game-gem.rb,
lib/bgg_search_result.rb,
lib/bgg_collection_item.rb,
lib/boardgamegem/version.rb
Defined Under Namespace
Classes: BGGBase, BGGCollection, BGGCollectionItem, BGGFamily, BGGItem, BGGSearchResult, BGGUser
Constant Summary
collapse
- API_ROOT =
"https://www.boardgamegeek.com/xmlapi2"
- MAX_ATTEMPTS =
10
- VERSION =
"0.3.9"
Class Method Summary
collapse
Class Method Details
.get_collection(username, options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/board-game-gem.rb', line 39
def self.get_collection(username, options = {})
options[:username] = username
collection_xml = BoardGameGem.request_xml("collection", options)
if collection_xml.css("error").length > 0
nil
else
BGGCollection.new(collection_xml)
end
end
|
.get_family(id, options = {}) ⇒ Object
27
28
29
30
31
|
# File 'lib/board-game-gem.rb', line 27
def self.get_family(id, options = {})
options[:id] = id
family = BGGFamily.new(BoardGameGem.request_xml("family", options))
family.id == 0 ? nil : family
end
|
.get_item(id, statistics = false, options = {}) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/board-game-gem.rb', line 8
def self.get_item(id, statistics = false, options = {})
options[:id] = id
options[:stats] = statistics ? 1 : 0
item = BGGItem.new(BoardGameGem.request_xml("thing", options))
item.id == 0 ? nil : item
end
|
.get_items(ids, statistics = false, options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/board-game-gem.rb', line 15
def self.get_items(ids, statistics = false, options = {})
options[:id] = ids.join(",")
options[:stats] = statistics ? 1 : 0
item_xml = BoardGameGem.request_xml("thing", options)
item_list = []
item_xml.css("item").wrap("<item_data></item_data>")
item_xml.css("item_data").each do |item_data|
item_list.push(BGGItem.new(item_data))
end
item_list
end
|
.get_user(username, options = {}) ⇒ Object
33
34
35
36
37
|
# File 'lib/board-game-gem.rb', line 33
def self.get_user(username, options = {})
options[:name] = username
user = BGGUser.new(BoardGameGem.request_xml("user", options))
user.id == 0 ? nil : user
end
|
.search(query, options = {}) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/board-game-gem.rb', line 49
def self.search(query, options = {})
options[:query] = query
xml = BoardGameGem.request_xml("search", options)
{
:total => xml.at_css("items")["total"].to_i,
:items => xml.css("item").map { |x| BGGSearchResult.new(x) }
}
end
|