Class: BoardGameGem::BGGCollection

Inherits:
BGGBase
  • Object
show all
Defined in:
lib/bgg_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ BGGCollection

Returns a new instance of BGGCollection.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bgg_collection.rb', line 6

def initialize(xml)
	if !xml.nil?
		@count = get_integer(xml, "items", "totalitems")
		@items = []
		xml.css("item").each do |item|
			@items.push(BGGCollectionItem.new(item))
		end
	else
		@count = -1
		@items = []
	end
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



4
5
6
# File 'lib/bgg_collection.rb', line 4

def count
  @count
end

#itemsObject

Returns the value of attribute items.



4
5
6
# File 'lib/bgg_collection.rb', line 4

def items
  @items
end

Instance Method Details

#get_for_tradeObject



52
53
54
# File 'lib/bgg_collection.rb', line 52

def get_for_trade
	return filter_by(:for_trade)
end

#get_ownedObject



24
25
26
# File 'lib/bgg_collection.rb', line 24

def get_owned
	return filter_by(:own)
end

#get_preorderedObject



48
49
50
# File 'lib/bgg_collection.rb', line 48

def get_preordered
	return filter_by(:preordered)
end

#get_previously_ownedObject



28
29
30
# File 'lib/bgg_collection.rb', line 28

def get_previously_owned
	return filter_by(:prev_owned)
end

#get_want_to_buyObject



40
41
42
# File 'lib/bgg_collection.rb', line 40

def get_want_to_buy
	return filter_by(:want_to_buy)
end

#get_want_to_playObject



36
37
38
# File 'lib/bgg_collection.rb', line 36

def get_want_to_play
	return filter_by(:want_to_play)
end

#get_wantsObject



32
33
34
# File 'lib/bgg_collection.rb', line 32

def get_wants
	return filter_by(:want)
end

#get_wishlistObject



44
45
46
# File 'lib/bgg_collection.rb', line 44

def get_wishlist
	return filter_by(:wishlist)
end

#status_of(id) ⇒ Object



19
20
21
22
# File 'lib/bgg_collection.rb', line 19

def status_of(id)
	item = @items.find { |x| x.id == id}
	item ? item.status : nil
end