Class: Bgg::Play
- Inherits:
-
Object
- Object
- Bgg::Play
- Defined in:
- lib/bgg/play.rb
Defined Under Namespace
Classes: Player
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#game_id ⇒ Object
readonly
Returns the value of attribute game_id.
-
#game_name ⇒ Object
readonly
Returns the value of attribute game_name.
-
#game_type ⇒ Object
readonly
Returns the value of attribute game_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
Instance Method Summary collapse
- #game ⇒ Object
- #incomplete? ⇒ Boolean
-
#initialize(play) ⇒ Play
constructor
A new instance of Play.
- #nowinstats? ⇒ Boolean
Constructor Details
#initialize(play) ⇒ Play
Returns a new instance of Play.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bgg/play.rb', line 6 def initialize(play) @id = play['id'].to_i @incomplete = play['incomplete'].to_i @game_id = play['item'][0]['objectid'].to_i @length = play['length'].to_i @nowinstats = play['nowinstats'].to_i @quantity = play['quantity'].to_i @game_name = play['item'][0]['name'] @game_type = play['item'][0]['subtypes'][0]['subtype'][0]['value'] @date = play['date'] @location = play['location'] @players = [] if play.has_key?('players') play['players'][0]['player'].each do |player| @players << Player.new(player) end end end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def date @date end |
#game_id ⇒ Object (readonly)
Returns the value of attribute game_id.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def game_id @game_id end |
#game_name ⇒ Object (readonly)
Returns the value of attribute game_name.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def game_name @game_name end |
#game_type ⇒ Object (readonly)
Returns the value of attribute game_type.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def game_type @game_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def id @id end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def length @length end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def location @location end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def players @players end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
3 4 5 |
# File 'lib/bgg/play.rb', line 3 def quantity @quantity end |
Instance Method Details
#game ⇒ Object
36 37 38 |
# File 'lib/bgg/play.rb', line 36 def game Bgg::Game.find_by_id(self.game_id) end |
#incomplete? ⇒ Boolean
32 33 34 |
# File 'lib/bgg/play.rb', line 32 def incomplete? @incomplete != 0 end |
#nowinstats? ⇒ Boolean
28 29 30 |
# File 'lib/bgg/play.rb', line 28 def nowinstats? @nowinstats != 0 end |