Class: Stattleship::TotalTeamStat

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#data

Class Method Details

.fetch(path:, params:) ⇒ Object


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

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

Instance Method Details

#lowercase_statObject


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

def lowercase_stat
  if humanized_stat
    humanized_stat.downcase
  end
end

#populateObject


21
22
23
24
25
26
# File 'lib/stattleship/total_team_stat.rb', line 21

def populate
  populate_teams(total_team_stat)
  populate_season(total_team_stat)

  total_team_stat
end

#to_sentenceObject


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

def to_sentence
  if season_name.nil?
    "The #{team.full_name} have #{StatFormatter.stat(stat_name: stat, value: total)} #{lowercase_stat}"
  else
    "The #{team.full_name} had #{StatFormatter.stat(stat_name: stat, value: total)} #{lowercase_stat} in the #{season_name} season"
  end
end