Class: Stattleship::FootballGameLog
- Defined in:
- lib/stattleship/football_game_logs.rb
Instance Method Summary collapse
- #build_statline(stat:) ⇒ Object
- #stat_abbreviation(stat_name:) ⇒ Object
- #stats ⇒ Object
- #to_sentence ⇒ Object
Methods inherited from GameLog
#city, #league_abbreviation, #league_name, #opponent_full_name, #opponent_name, #player_name, #scoreline, #team_full_name, #team_name, #venue
Instance Method Details
#build_statline(stat:) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/stattleship/football_game_logs.rb', line 36 def build_statline(stat:) name = stat.keys.first value = stat.values.first if value && value != 0 "#{StatFormatter.format(value: value)} #{stat_abbreviation(stat_name: name)}" end end |
#stat_abbreviation(stat_name:) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/stattleship/football_game_logs.rb', line 44 def stat_abbreviation(stat_name:) case stat_name.to_s when 'passer_rating' 'RTG' when 'tackles_solo' 'T' when 'tackles_assists' 'TA' when 'sacks_total' 'SCKS' when 'sacks_yards' 'SYDS' when 'passes_defensed' 'PD' when 'interceptions_total' 'INT' when 'interceptions_touchdown' 'INT TD' when 'fumbles_committed' 'F' when 'passes_completions' 'CMP' when 'passes_yards_gross' 'YDS' when 'passes_touchdowns' 'TD' when 'passes_interceptions' 'INT' when 'receptions_total' 'R' when 'receptions_yards' 'RYDS' when 'receptions_touchdowns' 'RTD' when 'receptions_looks' 'L' when 'rushes_attempts' 'R' when 'rushes_yards' 'RYDS' when 'rushes_touchdowns' 'RTD' when 'field_goals_made' 'FG' when 'extra_points_made' 'XP' when 'punts_total' 'punts_total' when 'points' 'PTS' else '' end end |
#stats ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stattleship/football_game_logs.rb', line 3 def stats [ { passer_rating: }, { tackles_solo: tackles_solo }, { tackles_assists: tackles_assists }, { sacks_total: sacks_total }, { sacks_yards: sacks_yards }, { passes_defensed: passes_defensed }, { interceptions_total: interceptions_total }, { interceptions_touchdown: interceptions_touchdown }, { fumbles_committed: fumbles_committed }, { passes_completions: passes_completions }, { passes_yards_gross: passes_yards_gross }, { passes_touchdowns: passes_touchdowns }, { passes_interceptions: passes_interceptions }, { receptions_total: receptions_total }, { receptions_yards: receptions_yards }, { receptions_touchdowns: receptions_touchdowns }, { receptions_looks: receptions_looks }, { rushes_attempts: rushes_attempts }, { rushes_yards: rushes_yards }, { rushes_touchdowns: rushes_touchdowns }, { field_goals_made: field_goals_made }, { extra_points_made: extra_points_made }, { punts_total: punts_total }, { points: points }, ].map { |stat| build_statline(stat: stat) }.compact end |
#to_sentence ⇒ Object
32 33 34 |
# File 'lib/stattleship/football_game_logs.rb', line 32 def to_sentence "#{player_name} #{stats.join(', ')} (#{game.name})" end |