Class: Bgg::Play

Inherits:
Object
  • Object
show all
Defined in:
lib/bgg/play.rb

Defined Under Namespace

Classes: Player

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/bgg/play.rb', line 3

def date
  @date
end

#game_idObject (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_nameObject (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_typeObject (readonly)

Returns the value of attribute game_type.



3
4
5
# File 'lib/bgg/play.rb', line 3

def game_type
  @game_type
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/bgg/play.rb', line 3

def id
  @id
end

#lengthObject (readonly)

Returns the value of attribute length.



3
4
5
# File 'lib/bgg/play.rb', line 3

def length
  @length
end

#locationObject (readonly)

Returns the value of attribute location.



3
4
5
# File 'lib/bgg/play.rb', line 3

def location
  @location
end

#playersObject (readonly)

Returns the value of attribute players.



3
4
5
# File 'lib/bgg/play.rb', line 3

def players
  @players
end

#quantityObject (readonly)

Returns the value of attribute quantity.



3
4
5
# File 'lib/bgg/play.rb', line 3

def quantity
  @quantity
end

Instance Method Details

#gameObject



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

def game
	Bgg::Game.find_by_id(self.game_id)
end

#incomplete?Boolean

Returns:

  • (Boolean)


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

def incomplete?
	@incomplete != 0
end

#nowinstats?Boolean

Returns:

  • (Boolean)


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

def nowinstats?
	@nowinstats != 0
end