baseball 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa54caafe28d80c5f1d5bfd3fb52d58d3e0b5dd84b787c90b7eeb97208be8439
4
- data.tar.gz: 82ac54c8286efde8e7874d55932f45a5e51cf1936b18baf61aa0c6c5737cef5a
3
+ metadata.gz: d02b487ff6f4d5e35050acf27f4343586ee50fe397aa8b16b92a530281470318
4
+ data.tar.gz: d756307de9cdaa037f6d7ab3b43ec973bd765f6b1ffd0421cf8e362b46411b2c
5
5
  SHA512:
6
- metadata.gz: '038b299268c4e9914c98ca2a57e1fa363edb906f57c3743f3f47cd04297e1751be12ef85f8712aeb82c355660688ba92b5002b07c59b60c5245a490fdf1605f5'
7
- data.tar.gz: 64f7aa0f21c737b3b3e3b2e97ca1497831a68ce371ad9413dbbaae52a32800310209bb0f2ad525942d757cb618688d75d1f37461791f5fe631667d9232058807
6
+ metadata.gz: 66563fa720fb7a89d6e4458be964cd32c7fc78a8c39788f122df64e7c3f3b5bdaf22742cc5fd92bf070bc453068d7aa7034f792d86498b6916ba1bb62eb43f76
7
+ data.tar.gz: 1b8a25ca4b5e01132ef9c656735845c01bbc5a7dec3dc9bfe2044b1ba387e156a2debede0af135dd8486aa2a0992c5e088ae9597121e97840cfb6a40acd91bd2
@@ -8,10 +8,10 @@ require 'baseball/player'
8
8
  module Baseball
9
9
 
10
10
  #table of contents
11
- #batter stats
12
- #pitcher stats
13
- # fielder stats
14
- # runner stats
11
+ #batting stats
12
+ #pitching stats
13
+ # fielding stats
14
+ # running stats
15
15
 
16
16
  def self.version_number
17
17
  Baseball::VERSION
@@ -43,7 +43,13 @@ module Baseball
43
43
  player.ops
44
44
  end
45
45
 
46
- #pitcher stats
46
+ def self.runs_created(player_hash)
47
+ include Batting
48
+ player = Batter.new(player_hash)
49
+ player.runs_created
50
+ end
51
+
52
+ #pitching stats
47
53
 
48
54
  def self.era(pitcher_hash)
49
55
  include Pitching
@@ -63,7 +69,7 @@ module Baseball
63
69
  pitcher.k_per_nine
64
70
  end
65
71
 
66
- #fielder stats
72
+ #fielding stats
67
73
 
68
74
  def self.fielding_percentage(fielder_hash)
69
75
  include Fielding
@@ -71,7 +77,7 @@ module Baseball
71
77
  fielder.fielding_percentage
72
78
  end
73
79
 
74
- # runner stats
80
+ # running stats
75
81
 
76
82
  def self.stolen_base_percentage(runner_hash)
77
83
  include Running
@@ -35,6 +35,15 @@ module Batting
35
35
  player_ops_string
36
36
  end
37
37
  end
38
+
39
+ def runs_created
40
+ opportunities = @player[:at_bats] + @player[:walks]
41
+ times_on_base = @player[:hits] + @player[:walks]
42
+ total_bases = @player[:singles] + (@player[:doubles] * 2) + (@player[:triples] * 3) + @player[:hr] * 4
43
+ total_production = total_bases * times_on_base
44
+ runs_created_figure = total_production.to_f / opportunities.to_f
45
+ runs_created_figure.round(2).to_s
46
+ end
38
47
  end
39
48
 
40
49
  end
@@ -7,23 +7,20 @@ module Pitching
7
7
  def era
8
8
  earned_runs = @player[:er] * 9
9
9
  avg = earned_runs / @player[:ip].to_f
10
- earned_run_average = avg.round(2)
11
- earned_run_average.to_s
10
+ avg.round(2).to_s
12
11
  end
13
12
 
14
13
  def whip
15
14
  corrected_innings = third_of_an_inning_handler(@player[:ip]).to_f
16
15
  walks_plus_hits = @player[:walks] + @player[:hits]
17
16
  figured_whip = walks_plus_hits / corrected_innings
18
- figured_whip = figured_whip.round(3)
19
- figured_whip.to_s
17
+ figured_whip.round(3).to_s
20
18
  end
21
19
 
22
20
  def k_per_nine
23
21
  full_games = @player[:ip] / 9
24
22
  so9 = @player[:so] / full_games.to_f
25
- so9_final = so9.round(1)
26
- so9_final.to_s
23
+ so9.round(1).to_s
27
24
  end
28
25
 
29
26
  end
@@ -7,16 +7,14 @@ module Running
7
7
  def stolen_base_percentage
8
8
  player_stolen_base_percentage = @player[:stolen_bases].to_f / (@player[:stolen_bases ].to_f + @player[:caught_stealing].to_f)
9
9
  stealing_average = player_stolen_base_percentage.round(3)
10
- average_string = remove_leading_zero(stealing_average)
11
- figure_lead_and_trailing_zeroes(average_string)
10
+ figure_lead_and_trailing_zeroes(stealing_average)
12
11
  end
13
12
 
14
13
  def stolen_base_runs
15
14
  stolen_base_adjustment = @player[:stolen_bases].to_f * 0.3
16
15
  caught_stealing_adjustment = @player[:caught_stealing].to_f * 0.6
17
16
  adjusted_stolen_base_runs = stolen_base_adjustment - caught_stealing_adjustment
18
- base_runs = adjusted_stolen_base_runs.round(3)
19
- return base_runs.to_s
17
+ adjusted_stolen_base_runs.round(3).to_s
20
18
  end
21
19
  end
22
20
 
@@ -1,3 +1,3 @@
1
1
  module Baseball
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baseball
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Busby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-23 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler