Class: Stattleship::Models::TeamOutcomeStreak
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Stattleship::Models::TeamOutcomeStreak
- Defined in:
- lib/stattleship/models/team_outcome_streak.rb
Instance Method Summary collapse
- #current? ⇒ Boolean
- #ended_on_short_date ⇒ Object
- #league_abbreviation ⇒ Object
- #league_name ⇒ Object
- #loss? ⇒ Boolean
- #outcome_participle ⇒ Object
- #started_on_short_date ⇒ Object
- #team_full_name ⇒ Object
- #team_location ⇒ Object
- #team_name ⇒ Object
- #team_nickname ⇒ Object
- #to_rank ⇒ Object
- #to_sentence ⇒ Object
- #win? ⇒ Boolean
Instance Method Details
#current? ⇒ Boolean
4 5 6 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 4 def current? current end |
#ended_on_short_date ⇒ Object
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_abbreviation ⇒ Object
12 13 14 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 12 def league_abbreviation league.abbreviation end |
#league_name ⇒ Object
8 9 10 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 8 def league_name league.name end |
#loss? ⇒ Boolean
52 53 54 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 52 def loss? outcome == 'loss' end |
#outcome_participle ⇒ Object
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_date ⇒ Object
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_name ⇒ Object
28 29 30 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 28 def team_full_name team.full_name end |
#team_location ⇒ Object
16 17 18 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 16 def team_location team.location end |
#team_name ⇒ Object
20 21 22 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 20 def team_name team.name end |
#team_nickname ⇒ Object
24 25 26 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 24 def team_nickname team.nickname end |
#to_rank ⇒ Object
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_sentence ⇒ Object
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
56 57 58 |
# File 'lib/stattleship/models/team_outcome_streak.rb', line 56 def win? outcome == 'win' end |