Class: SRL::Game
Overview
Summary information about a game run on SRL.
Defined Under Namespace
Classes: Runner, Statistics
Instance Attribute Summary collapse
-
#abbrev ⇒ Object
(also: #abbreviation, #short_name)
readonly
This game’s abbreviation, as used by RaceBot.
-
#leaders ⇒ Object
This game’s leaderboard, as an array of Players.
-
#leadersCount ⇒ Object
(also: #leaders_count, #num_leaders)
readonly
The amount of ranked players on this game’s leaderboard.
-
#name ⇒ Object
readonly
This game’s complete name.
-
#oid ⇒ Object
(also: #game_id)
readonly
This game’s ID as per the SRL data.
-
#popularity ⇒ Object
readonly
This game’s popularity rating, according to SRL data.
-
#popularityrank ⇒ Object
(also: #popularity_rank)
readonly
This game’s position in the popularity contest, according to SRL data.
-
#stats ⇒ Object
(also: #statistics)
Statistics about this game.
Instance Method Summary collapse
-
#leaders_by_rank(dir = :asc) ⇒ Object
An array of players on this game’s leaderboard, sorted by their rank.
Methods included from Unmarshalable
Instance Attribute Details
#abbrev ⇒ Object (readonly) Also known as: abbreviation, short_name
This game’s abbreviation, as used by RaceBot.
14 15 16 |
# File 'lib/srl/game.rb', line 14 def abbrev @abbrev end |
#leaders ⇒ Object
This game’s leaderboard, as an array of Players.
While generally sorted by rank, this method does not guarantee the order of the players return.
If you absolutely need them sorted, use the ‘leaders_by_rank` method or call `sort_by(&:rank)` on this value.
38 39 40 |
# File 'lib/srl/game.rb', line 38 def leaders @leaders end |
#leadersCount ⇒ Object (readonly) Also known as: leaders_count, num_leaders
The amount of ranked players on this game’s leaderboard.
27 28 29 |
# File 'lib/srl/game.rb', line 27 def leadersCount @leadersCount end |
#name ⇒ Object (readonly)
This game’s complete name.
11 12 13 |
# File 'lib/srl/game.rb', line 11 def name @name end |
#oid ⇒ Object (readonly) Also known as: game_id
This game’s ID as per the SRL data.
7 8 9 |
# File 'lib/srl/game.rb', line 7 def oid @oid end |
#popularity ⇒ Object (readonly)
This game’s popularity rating, according to SRL data.
19 20 21 |
# File 'lib/srl/game.rb', line 19 def popularity @popularity end |
#popularityrank ⇒ Object (readonly) Also known as: popularity_rank
This game’s position in the popularity contest, according to SRL data.
23 24 25 |
# File 'lib/srl/game.rb', line 23 def popularityrank @popularityrank end |
#stats ⇒ Object Also known as: statistics
Statistics about this game. Things like the number of races, number of players, total time played and raced.
- SEE
-
SRL::Statistics
47 48 49 |
# File 'lib/srl/game.rb', line 47 def stats @stats end |
Instance Method Details
#leaders_by_rank(dir = :asc) ⇒ Object
An array of players on this game’s leaderboard, sorted by their rank.
59 60 61 62 63 64 |
# File 'lib/srl/game.rb', line 59 def leaders_by_rank(dir = :asc) raise ArgumentError unless %i(asc desc).include?(dir) dir == :asc ? leaders.sort_by(&:rank) : leaders.sort_by(&:rank).reverse end |