Class: BoardGameGem::BGGCollectionItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ BGGCollectionItem

Returns a new instance of BGGCollectionItem.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bgg_collection_item.rb', line 6

def initialize(xml)
  @id = xml["objectid"].to_i
  @type = xml["subtype"]
  @name = get_string(xml, "name")
  @year_published = get_string(xml, "yearpublished")
  @image = get_string(xml, "image")
  @thumbnail = get_string(xml, "thumbnail")
  @num_players = get_string(xml, "numplayers")
  @status = {
    :own => get_boolean(xml, "status", "own"),
    :prev_owned => get_boolean(xml, "status", "prevowned"),
    :for_trade => get_boolean(xml, "status", "fortrade"),
    :want => get_boolean(xml, "status", "want"),
    :want_to_play => get_boolean(xml, "status", "wanttoplay"),
    :want_to_buy => get_boolean(xml, "status", "wanttobuy"),
    :wishlist => get_boolean(xml, "status", "wishlist"),
    :wishlist_priority => get_integer(xml, "status", "wishlistpriority"),
    :preordered => get_boolean(xml, "status", "preordered"),
    :last_modified => get_datetime(xml, "status", "lastmodified")
  }
  @num_plays = get_integer(xml, "numplays")
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image.



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

def image
  @image
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#num_playersObject (readonly)

Returns the value of attribute num_players.



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

def num_players
  @num_players
end

#num_playsObject (readonly)

Returns the value of attribute num_plays.



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

def num_plays
  @num_plays
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#thumbnailObject (readonly)

Returns the value of attribute thumbnail.



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

def thumbnail
  @thumbnail
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#year_publishedObject (readonly)

Returns the value of attribute year_published.



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

def year_published
  @year_published
end

Instance Method Details

#to_item(statistics = false) ⇒ Object



29
30
31
# File 'lib/bgg_collection_item.rb', line 29

def to_item(statistics = false)
  return BoardGameGem.get_item(@id, statistics)
end