Class: Stattleship::TotalPlayerStat
- Inherits:
-
Endpoint
- Object
- OpenStruct
- Endpoint
- Stattleship::TotalPlayerStat
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
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_stat ⇒ Object
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
|
#populate ⇒ Object
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_sentence ⇒ Object
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
|