Class: Player

Inherits:
Object
  • Object
show all
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

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

#nameObject



18
19
20
# File 'lib/player.rb', line 18

def name
  @data['name']
end

#player_classObject



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

def player_class
  short_class && PLAYER_CLASSES[short_class]
end

#scoreObject



22
23
24
# File 'lib/player.rb', line 22

def score
  @data['score']
end

#teamObject



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_rowObject



26
27
28
# File 'lib/player.rb', line 26

def to_row
  "#{emoji}#{name}"
end