Sha256: 8726edb8d3201683981e9b4ecb04c975c658a617fbc9a21549b80dedb142fbdc

Contents?: true

Size: 1.62 KB

Versions: 2

Compression:

Stored size: 1.62 KB

Contents

require 'baseball/version'
require 'baseball/batting'
require 'baseball/pitching'
require 'baseball/fielding'
require 'baseball/running'
require 'baseball/player'

module Baseball

  #table of contents
    #batter stats
    #pitcher stats
    # fielder stats
    # runner stats

  def self.version_number
    Baseball::VERSION
  end

  #batting stats

  def self.batting_average(player_hash)
    include Batting
    player = Batter.new(player_hash)
    player.batting_average
  end

  def self.obp(player_hash)
    include Batting
    player = Batter.new(player_hash)
    player.obp
  end

  def self.slg(player_hash)
    include Batting
    player = Batter.new(player_hash)
    player.slugging_percentage
  end

  def self.ops(player_hash)
    include Batting
    player = Batter.new(player_hash)
    player.ops
  end

  #pitcher stats

  def self.era(pitcher_hash)
    include Pitching
    pitcher = Pitcher.new(pitcher_hash)
    pitcher.era
  end

  def self.whip(pitcher_hash)
    include Pitching
    pitcher = Pitcher.new(pitcher_hash)
    pitcher.whip
  end

  def self.k_per_nine(pitcher_hash)
    include Pitching
    pitcher = Pitcher.new(pitcher_hash)
    pitcher.k_per_nine
  end

  #fielder stats

  def self.fielding_percentage(fielder_hash)
    include Fielding
    fielder = Fielder.new(fielder_hash)
    fielder.fielding_percentage
  end

  # runner stats

  def self.stolen_base_percentage(runner_hash)
    include Running
    runner = Runner.new(runner_hash)
    runner.stolen_base_percentage
  end

  def self.stolen_base_runs(runner_hash)
    include Running
    runner = Runner.new(runner_hash)
    runner.stolen_base_runs
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
baseball-1.1.0 lib/baseball.rb
baseball-1.0.0 lib/baseball.rb