Class: Stattleship::TotalPlayerStat

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/stattleship/total_player_stat.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#data

Class Method Details

.fetch(path:, params:) ⇒ Object


21
22
23
# File 'lib/stattleship/total_player_stat.rb', line 21

def self.fetch(path:, params:)
  super.first
end

Instance Method Details

#format_stat(value) ⇒ Object


17
18
19
# File 'lib/stattleship/total_player_stat.rb', line 17

def format_stat(value)
  StatFormatter.stat(stat_name: stat, value: total)
end

#lowercase_statObject


11
12
13
14
15
# File 'lib/stattleship/total_player_stat.rb', line 11

def lowercase_stat
  if humanized_stat
    humanized_stat.downcase
  end
end

#populateObject


25
26
27
28
29
30
# File 'lib/stattleship/total_player_stat.rb', line 25

def populate
  populate_players(total_player_stat)
  populate_player_teams(total_player_stat)
  populate_season(total_player_stat)
  total_player_stat
end

#to_sentenceObject


3
4
5
6
7
8
9
# File 'lib/stattleship/total_player_stat.rb', line 3

def to_sentence
  if season_name.nil?
    "#{player.name} has #{format_stat(total)} #{lowercase_stat}"
  else
    "#{player.name} had #{format_stat(total)} #{lowercase_stat} in the #{season_name} season"
  end
end