Class: BoardGameGem::BGGCollection
- Defined in:
- lib/bgg_collection.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
- #get_owned ⇒ Object
- #get_preordered ⇒ Object
- #get_previously_owned ⇒ Object
- #get_want_to_buy ⇒ Object
- #get_want_to_play ⇒ Object
- #get_wants ⇒ Object
- #get_wishlist ⇒ Object
-
#initialize(xml) ⇒ BGGCollection
constructor
A new instance of BGGCollection.
- #status_of(id) ⇒ Object
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
#count ⇒ Object
Returns the value of attribute count.
4 5 6 |
# File 'lib/bgg_collection.rb', line 4 def count @count end |
#items ⇒ Object
Returns the value of attribute items.
4 5 6 |
# File 'lib/bgg_collection.rb', line 4 def items @items end |
Instance Method Details
#get_owned ⇒ Object
24 25 26 |
# File 'lib/bgg_collection.rb', line 24 def get_owned return filter_by(:own) end |
#get_preordered ⇒ Object
48 49 50 |
# File 'lib/bgg_collection.rb', line 48 def get_preordered return filter_by(:preordered) end |
#get_previously_owned ⇒ Object
28 29 30 |
# File 'lib/bgg_collection.rb', line 28 def get_previously_owned return filter_by(:prev_owned) end |
#get_want_to_buy ⇒ Object
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_play ⇒ Object
36 37 38 |
# File 'lib/bgg_collection.rb', line 36 def get_want_to_play return filter_by(:want_to_play) end |
#get_wants ⇒ Object
32 33 34 |
# File 'lib/bgg_collection.rb', line 32 def get_wants return filter_by(:want) end |
#get_wishlist ⇒ Object
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 |