Bowling 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGVlMTE3NDU1MTRkZTYxMjk0MDdjMmM3ZjQzZWUxMDIwMTI5Nzk5NA==
4
+ ZWZlZTI1Yzc4NTBlOWMxZGNmZWUwZDFmY2M0NGQwNjAyMzkxOGY4ZA==
5
5
  data.tar.gz: !binary |-
6
- NmQ2OTM4ZWQ4Y2MxZTY1MmQ0M2Y3N2U5OTU3Y2IzY2I4MjVkNmI2OQ==
6
+ MjQ1MWM3OTJjMjRlYmIyYjFlNTFmZGNmMTY0ZTU1MzhlMzIyOTA1ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZTE1Nzc2ZWM3YTkwNTVlYzdiMjUxOGI1MGUwMjY3ZDVlMGNlZWU2MWRlMzAz
10
- MWY1NjJjODU3NTk5MzM4NGJiMTA0YjFhZWQzM2ZiNWE3MGEyYTAyYjAwMzNm
11
- ZTRlMWQ5ZTY0ODcwMjQ0OGUxOTRiNmI1MWRiMzA0ZjMwNGQ2ZWI=
9
+ NGFiN2E4MTk0YzczZjMyODU4OWFlNjg3YTBkNGEyYWNhMWU5NjIwNzNmMTIz
10
+ NzFmMTZhZmZiODM4NTljNzdkNmZhZWNiMjM3ZWI2OTg0NjQyNDc4N2E2MmNj
11
+ YTg3MzcyOWI1OGI0Y2QwMmY2MmUwZDVhOWU3NWViMjk5M2YzZjc=
12
12
  data.tar.gz: !binary |-
13
- ZDA3YjQ4MjI0ZGZlNjBmNDFmZTY5NzIzMjg1Y2VhMTExODAyZWFkOWY0MzIx
14
- MWQ0YWQ3YmIyNTcyMjUxNjEyYmY2ZGY4MmVmYzc4NmFmYTI5ZDI3NmZmNTVi
15
- OTE2MTYwN2Y3YzI4NjBjY2VlODVkMDkyNzhiNjBkODIxYjI1MDA=
13
+ YmU1MTM2MGFjNmI4M2M3MTNjM2JiZDRhMjVjNDE0OGMxMTJiNjMyMGYxZjg0
14
+ N2RjMWYzM2I1YjJiYmQ4ZTQ5MGRkYWUxNmM2YmYyYzNlODhjOWQyODU4ZDBi
15
+ NmVkM2U3ZDlhY2MyMzE4MjNmYTc0OTU4MmJmNzQzMzY4N2E3ZmM=
@@ -1,49 +1,49 @@
1
1
  class Bowling::Ball
2
2
 
3
- attr_accessor :ball_position, :knocked_pins, :frame
4
- alias_method :score, :knocked_pins
3
+ attr_accessor :ball_position, :knocked_pins, :frame
4
+ alias_method :score, :knocked_pins
5
5
 
6
6
 
7
- #= Construction ===
7
+ #= Construction ===
8
8
 
9
- def initialize( ball_position, frame, knocked_pins = nil )
10
- @ball_position = ball_position
11
- @frame = frame
12
- @knocked_pins = knocked_pins || 0
13
- end
9
+ def initialize( ball_position, frame, knocked_pins = nil )
10
+ @ball_position = ball_position
11
+ @frame = frame
12
+ @knocked_pins = knocked_pins || 0
13
+ end
14
14
 
15
15
 
16
- #= Public methods ===
16
+ #= Public methods ===
17
17
 
18
- def knock_over( amount )
19
- knocked_pins += amount
20
- raise Error.new 'Knocked pins can not exceed 10' if knocked_pins > 10
21
- end
18
+ def knock_over( amount )
19
+ knocked_pins += amount
20
+ raise Error.new 'Knocked pins can not exceed 10' if knocked_pins > 10
21
+ end
22
22
 
23
23
 
24
- def next_ball
25
- if strike?
26
- frame.next_frame.first_ball
27
- else
28
- frame.balls[ball_position + 1]
29
- end
30
- end
24
+ def next_ball
25
+ if strike?
26
+ frame.next_frame.first_ball
27
+ else
28
+ frame.balls[ball_position + 1]
29
+ end
30
+ end
31
31
 
32
32
 
33
- #= Calculations ===
33
+ #= Calculations ===
34
34
 
35
- def strike?
36
- first_ball? and perfect?
37
- end
35
+ def strike?
36
+ first_ball? and perfect?
37
+ end
38
38
 
39
39
 
40
- def perfect?
41
- knocked_pins == 10
42
- end
43
-
40
+ def perfect?
41
+ knocked_pins == 10
42
+ end
43
+
44
44
 
45
- def first_ball?
46
- ball_position == 0
47
- end
45
+ def first_ball?
46
+ ball_position == 0
47
+ end
48
48
 
49
49
  end
@@ -1,10 +1,10 @@
1
1
  class Bowling::NullBall < NilClass
2
- class << self
2
+ class << self
3
3
 
4
- def score ; 0 ; end
5
- def knocked_pins ; 0 ; end
6
- def strike? ; false ; end
7
- def perfect? ; false ; end
4
+ def score ; 0 ; end
5
+ def knocked_pins ; 0 ; end
6
+ def strike? ; false ; end
7
+ def perfect? ; false ; end
8
8
 
9
- end
9
+ end
10
10
  end
@@ -1,9 +1,9 @@
1
1
  class Bowling::NullFrame < NilClass
2
- class << self
2
+ class << self
3
3
 
4
- def strike? ; false ; end
5
- def balls ; [] ; end
6
- def first_ball ; Bowling::NullBall ; end
7
-
8
- end
4
+ def strike? ; false ; end
5
+ def balls ; [] ; end
6
+ def first_ball ; Bowling::NullBall ; end
7
+
8
+ end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Bowling
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
 
4
4
  describe Bowling::Ball do
5
-
6
- subject( :instance ){ Bowling::Ball.new 1, frame }
5
+
6
+ subject( :instance ){ Bowling::Ball.new 1, frame }
7
7
 
8
8
 
9
- #= Lets ===
9
+ #= Lets ===
10
10
 
11
- let( :game ){ Bowling::Game.new }
12
- let( :frame ){ Bowling::Frame.new 1, game }
11
+ let( :game ){ Bowling::Game.new }
12
+ let( :frame ){ Bowling::Frame.new 1, game }
13
13
 
14
14
 
15
- #= Specs ===
16
-
17
- its( :knocked_pins ){ should equal 0 }
15
+ #= Specs ===
16
+
17
+ its( :knocked_pins ){ should equal 0 }
18
18
 
19
19
  end
@@ -2,9 +2,7 @@ require 'spec_helper'
2
2
 
3
3
 
4
4
  describe Bowling::Frame do
5
-
6
- subject( :row_number ){ 1 }
7
- subject( :instance ){ described_class.new row_number, game }
5
+ subject( :instance ){ described_class.new 1, game }
8
6
 
9
7
 
10
8
  #= Lets ===
@@ -40,8 +38,6 @@ describe Bowling::Frame do
40
38
  #= General Specs ===
41
39
 
42
40
  describe 'with perfect final frame' do
43
- let( :row_number ){ 9 }
44
-
45
41
  subject{ described_class.new 9, game, perfect_final_frame }
46
42
 
47
43
  specify{ subject.balls.length.should == 3 }
@@ -3,117 +3,117 @@ require 'spec_helper'
3
3
 
4
4
  describe Bowling::Game do
5
5
 
6
- #= Lets ===
7
-
8
- let( :perfect_game ){ Array.new( 9 ){ [ 10 ] } << [ 10, 10, 10 ] }
9
- let( :spare_game ){ Array.new( 9 ){ [ 0, 10 ] } << [ 0, 10, 0 ] }
10
- let( :all_ones ){ Array.new( 9 ){ [ 1, 1 ] } << [ 1, 1 ] }
11
- let( :all_twos ){ Array.new( 9 ){ [ 2, 2 ] } << [ 2, 2 ] }
12
-
13
- let( :geometric_game ){ Array.new( 9 ){ |i| [ i, i ] } << [ 10, 10, 10 ] }
14
-
15
-
16
- #= Specs ===
17
-
18
- subject{ described_class.new }
19
-
20
- it{ should respond_to :frames }
21
-
22
-
23
- describe '#score' do
24
- context 'with perfect_game data' do
25
- before( :each ){ subject.load perfect_game }
26
-
27
- its( :score ){ should == 300 }
28
-
29
- specify( 'all frames have a score of 30' ){
30
- subject.frames.each do |frame|
31
- frame.score.should equal 30
32
- end
33
- }
34
-
35
- describe 'penultimate frame' do
36
- specify{ subject.frames[8].base_score.should equal 10 }
37
- specify{ subject.frames[8].strike_score.should equal 20 }
38
- specify{ subject.frames[8].spare_score.should equal 0 }
39
-
40
- specify{ subject.frames[8].next_ball.ball_position.should equal 0 }
41
- specify{ subject.frames[8].next_next_ball.ball_position.should equal 1 }
42
- end
43
- end
44
-
45
- context 'with spare_game data' do
46
- before( :each ){ subject.load spare_game }
47
-
48
- its( :score ){ should == 100 }
49
-
50
- specify( 'all frames have a score of 30' ){
51
- subject.frames.each do |frame|
52
- frame.score.should equal 10
53
- end
54
- }
55
-
56
- describe 'ultimate frame' do
57
- specify{ subject.frames[9].base_score.should equal 10 }
58
- specify{ subject.frames[9].strike_score.should equal 0 }
59
- specify{ subject.frames[9].spare_score.should equal 0 }
60
- end
61
- end
62
-
63
- context 'with all_ones data' do
64
- before( :each ){ subject.load all_ones }
65
-
66
- its( :score ){ should == 20 }
67
- end
68
-
69
- context 'with all_twos data' do
70
- before( :each ){ subject.load all_twos }
71
-
72
- its( :score ){ should == 40 }
73
- end
74
-
75
- context 'with geometric_game data' do
76
- before( :each ){ subject.load geometric_game }
77
-
78
- describe '#base_score' do
79
- specify{ subject.frames[ 0].base_score.should equal 0 }
80
- specify{ subject.frames[ 1].base_score.should equal 2 }
81
- specify{ subject.frames[ 2].base_score.should equal 4 }
82
- specify{ subject.frames[ 3].base_score.should equal 6 }
83
- specify{ subject.frames[ 4].base_score.should equal 8 }
84
- specify{ subject.frames[ 5].base_score.should equal 10 }
85
- specify{ subject.frames[ 6].base_score.should equal 10 }
86
- specify{ subject.frames[ 7].base_score.should equal 10 }
87
- specify{ subject.frames[ 8].base_score.should equal 10 }
88
- specify{ subject.frames[ 9].base_score.should equal 10 }
89
- end
90
-
91
- describe '#spare_score' do
92
- specify{ subject.frames[ 0].spare_score.should equal 0 }
93
- specify{ subject.frames[ 1].spare_score.should equal 0 }
94
- specify{ subject.frames[ 2].spare_score.should equal 0 }
95
- specify{ subject.frames[ 3].spare_score.should equal 0 }
96
- specify{ subject.frames[ 4].spare_score.should equal 0 }
97
- specify{ subject.frames[ 5].spare_score.should equal 6 }
98
- specify{ subject.frames[ 6].spare_score.should equal 7 }
99
- specify{ subject.frames[ 7].spare_score.should equal 8 }
100
- specify{ subject.frames[ 8].spare_score.should equal 10 }
101
- specify{ subject.frames[ 9].spare_score.should equal 0 }
102
- end
103
-
104
- describe '#strike_score' do
105
- specify{ subject.frames[ 0].strike_score.should equal 0 }
106
- specify{ subject.frames[ 1].strike_score.should equal 0 }
107
- specify{ subject.frames[ 2].strike_score.should equal 0 }
108
- specify{ subject.frames[ 3].strike_score.should equal 0 }
109
- specify{ subject.frames[ 4].strike_score.should equal 0 }
110
- specify{ subject.frames[ 5].strike_score.should equal 0 }
111
- specify{ subject.frames[ 6].strike_score.should equal 0 }
112
- specify{ subject.frames[ 7].strike_score.should equal 0 }
113
- specify{ subject.frames[ 8].strike_score.should equal 0 }
114
- specify{ subject.frames[ 9].strike_score.should equal 20 }
115
- end
116
- end
117
- end
6
+ #= Lets ===
7
+
8
+ let( :perfect_game ){ Array.new( 9 ){ [ 10 ] } << [ 10, 10, 10 ] }
9
+ let( :spare_game ){ Array.new( 9 ){ [ 0, 10 ] } << [ 0, 10, 0 ] }
10
+ let( :all_ones ){ Array.new( 9 ){ [ 1, 1 ] } << [ 1, 1 ] }
11
+ let( :all_twos ){ Array.new( 9 ){ [ 2, 2 ] } << [ 2, 2 ] }
12
+
13
+ let( :geometric_game ){ Array.new( 9 ){ |i| [ i, i ] } << [ 10, 10, 10 ] }
14
+
15
+
16
+ #= Specs ===
17
+
18
+ subject{ described_class.new }
19
+
20
+ it{ should respond_to :frames }
21
+
22
+
23
+ describe '#score' do
24
+ context 'with perfect_game data' do
25
+ before( :each ){ subject.load perfect_game }
26
+
27
+ its( :score ){ should == 300 }
28
+
29
+ specify( 'all frames have a score of 30' ){
30
+ subject.frames.each do |frame|
31
+ frame.score.should equal 30
32
+ end
33
+ }
34
+
35
+ describe 'penultimate frame' do
36
+ specify{ subject.frames[8].base_score.should equal 10 }
37
+ specify{ subject.frames[8].strike_score.should equal 20 }
38
+ specify{ subject.frames[8].spare_score.should equal 0 }
39
+
40
+ specify{ subject.frames[8].next_ball.ball_position.should equal 0 }
41
+ specify{ subject.frames[8].next_next_ball.ball_position.should equal 1 }
42
+ end
43
+ end
44
+
45
+ context 'with spare_game data' do
46
+ before( :each ){ subject.load spare_game }
47
+
48
+ its( :score ){ should == 100 }
49
+
50
+ specify( 'all frames have a score of 30' ){
51
+ subject.frames.each do |frame|
52
+ frame.score.should equal 10
53
+ end
54
+ }
55
+
56
+ describe 'ultimate frame' do
57
+ specify{ subject.frames[9].base_score.should equal 10 }
58
+ specify{ subject.frames[9].strike_score.should equal 0 }
59
+ specify{ subject.frames[9].spare_score.should equal 0 }
60
+ end
61
+ end
62
+
63
+ context 'with all_ones data' do
64
+ before( :each ){ subject.load all_ones }
65
+
66
+ its( :score ){ should == 20 }
67
+ end
68
+
69
+ context 'with all_twos data' do
70
+ before( :each ){ subject.load all_twos }
71
+
72
+ its( :score ){ should == 40 }
73
+ end
74
+
75
+ context 'with geometric_game data' do
76
+ before( :each ){ subject.load geometric_game }
77
+
78
+ describe '#base_score' do
79
+ specify{ subject.frames[ 0].base_score.should equal 0 }
80
+ specify{ subject.frames[ 1].base_score.should equal 2 }
81
+ specify{ subject.frames[ 2].base_score.should equal 4 }
82
+ specify{ subject.frames[ 3].base_score.should equal 6 }
83
+ specify{ subject.frames[ 4].base_score.should equal 8 }
84
+ specify{ subject.frames[ 5].base_score.should equal 10 }
85
+ specify{ subject.frames[ 6].base_score.should equal 10 }
86
+ specify{ subject.frames[ 7].base_score.should equal 10 }
87
+ specify{ subject.frames[ 8].base_score.should equal 10 }
88
+ specify{ subject.frames[ 9].base_score.should equal 10 }
89
+ end
90
+
91
+ describe '#spare_score' do
92
+ specify{ subject.frames[ 0].spare_score.should equal 0 }
93
+ specify{ subject.frames[ 1].spare_score.should equal 0 }
94
+ specify{ subject.frames[ 2].spare_score.should equal 0 }
95
+ specify{ subject.frames[ 3].spare_score.should equal 0 }
96
+ specify{ subject.frames[ 4].spare_score.should equal 0 }
97
+ specify{ subject.frames[ 5].spare_score.should equal 6 }
98
+ specify{ subject.frames[ 6].spare_score.should equal 7 }
99
+ specify{ subject.frames[ 7].spare_score.should equal 8 }
100
+ specify{ subject.frames[ 8].spare_score.should equal 10 }
101
+ specify{ subject.frames[ 9].spare_score.should equal 0 }
102
+ end
103
+
104
+ describe '#strike_score' do
105
+ specify{ subject.frames[ 0].strike_score.should equal 0 }
106
+ specify{ subject.frames[ 1].strike_score.should equal 0 }
107
+ specify{ subject.frames[ 2].strike_score.should equal 0 }
108
+ specify{ subject.frames[ 3].strike_score.should equal 0 }
109
+ specify{ subject.frames[ 4].strike_score.should equal 0 }
110
+ specify{ subject.frames[ 5].strike_score.should equal 0 }
111
+ specify{ subject.frames[ 6].strike_score.should equal 0 }
112
+ specify{ subject.frames[ 7].strike_score.should equal 0 }
113
+ specify{ subject.frames[ 8].strike_score.should equal 0 }
114
+ specify{ subject.frames[ 9].strike_score.should equal 20 }
115
+ end
116
+ end
117
+ end
118
118
 
119
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Bowling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Richardson