Class: Stattleship::BaseballGameLog

Inherits:
GameLog
  • Object
show all
Defined in:
lib/stattleship/baseball_game_logs.rb

Instance Method Summary collapse

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

#statsObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stattleship/baseball_game_logs.rb', line 3

def stats
  if player.pitcher?
    [
      "#{pitcher_strikeouts.to_i} K",
      "#{pitches_thrown.to_i} thrown",
      "#{strikes_thrown.to_i} K thrown",
      "#{pitcher_runs.to_i} R"
    ]
  else
    [
      "#{hits.to_i} H",
      "#{runs.to_i} R",
      "#{runs_batted_in.to_i} RBI",
      "#{fielding_errors.to_i} E"
    ]
  end
end

#to_sentenceObject


21
22
23
# File 'lib/stattleship/baseball_game_logs.rb', line 21

def to_sentence
  "#{player_name} #{stats.join(', ')} (#{game.name})"
end