Sha256: 2d007d7267277242767534463ec05c892420c18f34517e9c3d87c858d2a2aaab

Contents?: true

Size: 450 Bytes

Versions: 2

Compression:

Stored size: 450 Bytes

Contents

module Pitching

  class Pitcher
    attr_accessor :pitcher_hash
    def initialize(pitcher_hash)
      @pitcher = pitcher_hash
    end

    def era
      earned_runs = @pitcher[:er] * 9
      avg = earned_runs / @pitcher[:ip].to_f
      earned_run_average = avg.round(2)
    end

    def whip
      walks_plus_hits = @pitcher[:walks] + @pitcher[:hits]
      whip = walks_plus_hits / @pitcher[:ip].to_f
      whip = whip.round(3)
    end
  end


end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baseball-0.3.1 lib/baseball/pitching.rb
baseball-0.1.0 lib/baseball/pitching.rb