Class: Quaker3::Game
- Inherits:
-
Object
- Object
- Quaker3::Game
- Defined in:
- lib/quaker3/game.rb
Overview
Represents the Game model extract from Quake 3 Arena log file
Constant Summary collapse
- KILLER_WORLD =
'<world>'
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#kills ⇒ Object
Returns the value of attribute kills.
Instance Method Summary collapse
-
#initialize ⇒ Game
constructor
A new instance of Game.
-
#to_h ⇒ Hash
Generate a hash that represent’s a Game model.
-
#to_h_grouped ⇒ Hash
Generate a hash that represent’s a Game grouped statistics.
-
#to_h_grouped_by_mode ⇒ Hash
Generate a hash that represent’s a Game grouped by kill mode.
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
11 12 13 |
# File 'lib/quaker3/game.rb', line 11 def initialize @kills = [] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/quaker3/game.rb', line 7 def id @id end |
#kills ⇒ Object
Returns the value of attribute kills.
7 8 9 |
# File 'lib/quaker3/game.rb', line 7 def kills @kills end |
Instance Method Details
#to_h ⇒ Hash
Generate a hash that represent’s a Game model
17 18 19 20 21 22 23 |
# File 'lib/quaker3/game.rb', line 17 def to_h { 'id' => @id, 'total_kills' => @kills.length, 'kills' => @kills.map(&:to_h) } end |
#to_h_grouped ⇒ Hash
Generate a hash that represent’s a Game grouped statistics
27 28 29 30 31 32 33 34 |
# File 'lib/quaker3/game.rb', line 27 def to_h_grouped { 'id' => @id, 'total_kills' => @kills.length, 'players' => players, 'score' => score.sort { |a, b| b[:score] <=> a[:score] } } end |
#to_h_grouped_by_mode ⇒ Hash
Generate a hash that represent’s a Game grouped by kill mode
38 39 40 41 42 43 44 |
# File 'lib/quaker3/game.rb', line 38 def to_h_grouped_by_mode { 'id' => @id, 'total_kills' => @kills.length, 'modes' => modes } end |