Class: Stattleship::Models::TeamOutcomeStreak

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/stattleship/models/team_outcome_streak.rb

Instance Method Summary collapse

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)

4
5
6
# File 'lib/stattleship/models/team_outcome_streak.rb', line 4

def current?
  current
end

#ended_on_short_dateObject


64
65
66
# File 'lib/stattleship/models/team_outcome_streak.rb', line 64

def ended_on_short_date
  ended_on.to_datetime.strftime('%b %d')
end

#league_abbreviationObject


12
13
14
# File 'lib/stattleship/models/team_outcome_streak.rb', line 12

def league_abbreviation
  league.abbreviation
end

#league_nameObject


8
9
10
# File 'lib/stattleship/models/team_outcome_streak.rb', line 8

def league_name
  league.name
end

#loss?Boolean

Returns:

  • (Boolean)

52
53
54
# File 'lib/stattleship/models/team_outcome_streak.rb', line 52

def loss?
  outcome == 'loss'
end

#outcome_participleObject


44
45
46
47
48
49
50
# File 'lib/stattleship/models/team_outcome_streak.rb', line 44

def outcome_participle
  if win?
    'winning'
  else
    'losing'
  end
end

#started_on_short_dateObject


60
61
62
# File 'lib/stattleship/models/team_outcome_streak.rb', line 60

def started_on_short_date
   started_on.to_datetime.strftime('%b %d')
end

#team_full_nameObject


28
29
30
# File 'lib/stattleship/models/team_outcome_streak.rb', line 28

def team_full_name
  team.full_name
end

#team_locationObject


16
17
18
# File 'lib/stattleship/models/team_outcome_streak.rb', line 16

def team_location
  team.location
end

#team_nameObject


20
21
22
# File 'lib/stattleship/models/team_outcome_streak.rb', line 20

def team_name
  team.name
end

#team_nicknameObject


24
25
26
# File 'lib/stattleship/models/team_outcome_streak.rb', line 24

def team_nickname
  team.nickname
end

#to_rankObject


40
41
42
# File 'lib/stattleship/models/team_outcome_streak.rb', line 40

def to_rank
  "#{team_full_name} #{rank.ordinalize} streak of the season is a #{streak_length} game #{outcome} streak between #{started_on_short_date} and #{ended_on_short_date}."
end

#to_sentenceObject


32
33
34
35
36
37
38
# File 'lib/stattleship/models/team_outcome_streak.rb', line 32

def to_sentence
  if current
    "#{team_full_name} are currently on a #{streak_length} game #{outcome_participle} streak starting #{started_on_short_date}"
  else
    "#{team_full_name} had a #{streak_length} game #{outcome_participle} streak between #{started_on_short_date} and #{ended_on_short_date}"
  end
end

#win?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'lib/stattleship/models/team_outcome_streak.rb', line 56

def win?
  outcome == 'win'
end