Class: Player
- Inherits:
-
Object
- Object
- Player
- Defined in:
- lib/player.rb
Constant Summary collapse
- PLAYER_CLASSES =
{ 'sco' => 'scout', 'sni' => 'sniper', 'sol' => 'soldier', 'dem' => 'demoman', 'med' => 'medic', 'pyr' => 'pyro', 'hwg' => 'hwguy', 'spy' => 'spy', 'eng' => 'engineer' }.freeze
Instance Method Summary collapse
-
#initialize(data) ⇒ Player
constructor
A new instance of Player.
- #name ⇒ Object
- #player_class ⇒ Object
- #score ⇒ Object
- #team ⇒ Object
- #to_row ⇒ Object
Constructor Details
#initialize(data) ⇒ Player
Returns a new instance of Player.
14 15 16 |
# File 'lib/player.rb', line 14 def initialize(data) @data = data end |
Instance Method Details
#name ⇒ Object
18 19 20 |
# File 'lib/player.rb', line 18 def name @data['name'] end |
#player_class ⇒ Object
36 37 38 |
# File 'lib/player.rb', line 36 def player_class short_class && PLAYER_CLASSES[short_class] end |
#score ⇒ Object
22 23 24 |
# File 'lib/player.rb', line 22 def score @data['score'] end |
#team ⇒ Object
30 31 32 33 34 |
# File 'lib/player.rb', line 30 def team return 'spec' if !valid_score? || @data['team'].empty? || @data['team'] == 'observe' @data['team'] end |
#to_row ⇒ Object
26 27 28 |
# File 'lib/player.rb', line 26 def to_row "#{emoji}#{name}" end |