Class: Stattleship::Models::Penalty

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

Direct Known Subclasses

HockeyPenalty

Instance Method Summary collapse

Instance Method Details

#atObject


96
97
98
# File 'lib/stattleship/models/penalty.rb', line 96

def at
  "#{period_time} of #{period}"
end

#away_teamObject


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

def away_team
  game.away_team
end

#away_team_nameObject


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

def away_team_name
  away_team.name
end

#cityObject


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

def city
  venue.city
end

#home_teamObject


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

def home_team
  game.home_team
end

#home_team_nameObject


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

def home_team_name
  home_team.name
end

#league_abbreviationObject


36
37
38
# File 'lib/stattleship/models/penalty.rb', line 36

def league_abbreviation
  league.abbreviation
end

#league_nameObject


32
33
34
# File 'lib/stattleship/models/penalty.rb', line 32

def league_name
  league.name
end

#opponent_full_nameObject


48
49
50
# File 'lib/stattleship/models/penalty.rb', line 48

def opponent_full_name
  opponent.full_name
end

#opponent_nameObject


44
45
46
# File 'lib/stattleship/models/penalty.rb', line 44

def opponent_name
  opponent.name
end

#periodObject


92
93
94
# File 'lib/stattleship/models/penalty.rb', line 92

def period
  "#{period_number}#{period_abbreviation}"
end

#period_abbreviationObject


84
85
86
87
88
89
90
# File 'lib/stattleship/models/penalty.rb', line 84

def period_abbreviation
  if game.hockey?
    "P"
  else
    "Q"
  end
end

#period_timeObject


80
81
82
# File 'lib/stattleship/models/penalty.rb', line 80

def period_time
  Time.at(period_seconds).utc.strftime('%M:%S')
end

#player_nameObject


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

def player_name
  player.name
end

#scorelineObject


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

def scoreline
  game.scoreline
end

#subject_nameObject


72
73
74
75
76
77
78
# File 'lib/stattleship/models/penalty.rb', line 72

def subject_name
  if team_penalty
    team_name
  else
    "#{player_name} (#{team_name})"
  end
end

#team_full_nameObject


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

def team_full_name
  team.full_name
end

#team_nameObject


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

def team_name
  team.name
end

#to_sentenceObject


106
107
108
# File 'lib/stattleship/models/penalty.rb', line 106

def to_sentence
  "#{subject_name} - #{label} - #{minutes} minutes - #{at} - #{vs}"
end

#venueObject


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

def venue
  game.venue
end

#venue_nameObject


68
69
70
# File 'lib/stattleship/models/penalty.rb', line 68

def venue_name
  venue.name
end

#vsObject


100
101
102
103
104
# File 'lib/stattleship/models/penalty.rb', line 100

def vs
  if game
    "vs #{opponent_name} #{game.short_date}"
  end
end

#winning_teamObject


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

def winning_team
  game.winning_team
end

#winning_team_nameObject


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

def winning_team_name
  winning_team.name
end