Class: Fielding::Fielder

Inherits:
Player::PlayerTemplate show all
Defined in:
lib/baseball/fielding.rb

Instance Attribute Summary

Attributes inherited from Player::PlayerTemplate

#player

Instance Method Summary collapse

Methods inherited from Player::PlayerTemplate

#figure_trailing_zeroes, #initialize

Constructor Details

This class inherits a constructor from Player::PlayerTemplate

Instance Method Details

#fielding_percentageObject



7
8
9
10
11
12
13
14
15
# File 'lib/baseball/fielding.rb', line 7

def fielding_percentage
  plays = @player[:put_outs] + @player[:assists]
  plays_plus_errors = plays + @player[:errors]
  player_avg = plays.to_f / plays_plus_errors.to_f
  avg = player_avg.round(3)
  # code smell - make this a several function called somewhere since this is used over multiple stats
  fielding_percentage = avg.to_s.sub!("0", "")
  figure_trailing_zeroes(fielding_percentage)
end