bb_stats_crunch 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/bb_stats_crunch.rb +25 -23
  2. metadata +2 -2
@@ -1,20 +1,25 @@
1
- class BbStatsCrunch
2
- attr_accessor :team1, :team2, :score1, :score2
3
-
4
1
  require 'csv'
5
- hometeam = 0
6
- visteam = 0
7
- puts "#{hometeam.class}"
2
+ class BbStatsCrunch
3
+
4
+ attr_accessor :team1, :team2, :score1, :score2, :viswins, :homewins
8
5
 
6
+ def initialize(team1, team2, score1, score2, viswins, homewins, totalscore)
7
+ @team1 = team1
8
+ @team2 = team2
9
+ @score1 = Float(score1)
10
+ @score2 = Float(score2)
11
+ @viswins = Float(viswins)
12
+ @homewins = Float(homewins)
13
+ @totalscore = Float(totalscore)
14
+ end
9
15
 
10
- module GetStats
11
- hometeam, visteam, totalscore = 0, 0, 0
16
+ # puts "enter year (valid year between 1960 - 1969)"
17
+ # year = gets.chomp
12
18
 
13
- puts "enter year (valid year between 1960 - 1969)"
14
- year = gets.chomp
15
- teamwins = Hash.new("0")
16
- puts year
19
+ year = 1960
20
+ homewins, viswins, totalscore = 0, 0, 0
17
21
 
22
+ File.open("files/GL#{year}.OUTPUT", 'w') do |content|
18
23
  CSV.foreach("files/GL#{year}.TXT") do |row|
19
24
  team1 = row[3]
20
25
  score1 = row[9].to_i
@@ -22,18 +27,15 @@ puts year
22
27
  score2 = row[10].to_i
23
28
  totalscore = totalscore + score1 + score2
24
29
  if score1 > score2
25
- visteam += 1
26
- # puts teamwins["#{team1}"]
27
- # teamwins["#{team1}"]
28
- # teamwins["#{team1}"] += 1
29
- # puts @teamwins["#{team1}"]
30
+ viswins += 1
31
+ content.puts "#{team1} beat #{team2} by a score of #{score1} to #{score2}"
30
32
  else
31
- hometeam += 1
33
+ homewins += 1
34
+ content.puts "#{team2} beat #{team1} by a score of #{score2} to #{score1}"
32
35
  end
36
+ end
33
37
  end
34
- puts "The home team won #{hometeam} times."
35
- puts "The vistors won #{visteam} times."
36
- puts "Total runs scored in #{year} was #{totalscore}."
37
-
38
- end
38
+ puts "The home team won #{homewins} times."
39
+ puts "The vistors won #{viswins} times."
40
+ puts "Total runs scored in #{year} was #{totalscore}."
39
41
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 10
9
- version: 0.0.10
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jack Howland