tennis 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +1 -1
- data/lib/tennis/version.rb +1 -1
- data/lib/tennis.rb +4 -4
- data/spec/tennis_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071d8da8d7b39b88163c917635cff96a913bafcd
|
4
|
+
data.tar.gz: 63252be0e608ee1d0f597d36c0333d24b8256606
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9a0401551a28c70dd2cd3106196c3ec3d8723ff603ed5ef7250c077e3d76c41f74747a698594fb58929c41c154cdfdb92c880b08814b639569732b4457e2d67
|
7
|
+
data.tar.gz: 66c54ec51b6a0f6520d4caa602c3eacdd950eb43736c749da85a4f294cbca106b820cf8c35a4f9d0faa209be8cd24d2d5337f369b5ac61cc59186b4198986399
|
data/Makefile
CHANGED
data/lib/tennis/version.rb
CHANGED
data/lib/tennis.rb
CHANGED
@@ -45,15 +45,15 @@ class Tennis
|
|
45
45
|
scores_string
|
46
46
|
else
|
47
47
|
# check blank input ''
|
48
|
-
validation_1 = set_scores.any? {|score| score.nil?}
|
48
|
+
validation_1 = set_scores.any? { |score| score.nil? }
|
49
49
|
# to check if score for only 1 set has been input
|
50
50
|
validation_2 = set_scores.length == 2
|
51
51
|
# to check if any input > 7
|
52
|
-
validation_3 = set_scores.any? {|score| score > 7}
|
52
|
+
validation_3 = set_scores.any? { |score| score > 7 }
|
53
53
|
# to check if one of the input is 7 and the other is not 6
|
54
54
|
# bad tie break input
|
55
55
|
validation_4 = false
|
56
|
-
set_scores.each_slice(2).each {|r| validation_4 = true if r.any? {|score| score == 7} && !r.any? {|score| score == 6} }
|
56
|
+
set_scores.each_slice(2).each { |r| validation_4 = true if r.any? { |score| score == 7 } && !r.any? { |score| score == 6 || score == 5 } }
|
57
57
|
@winner = :error if validation_1 || validation_2 || validation_3 || validation_4
|
58
58
|
# if set score is not complete eg: 4-6,7-6,4-1
|
59
59
|
set_scores.each_slice(2).each {|r| @winner = :incomplete_match if r[0] < 6 && r[1] < 6 } unless @winner == :error
|
@@ -75,7 +75,7 @@ class Tennis
|
|
75
75
|
# returns (0,0) for bad input
|
76
76
|
def match_points
|
77
77
|
return [0, 0] if @winner == :error
|
78
|
-
return [@scores == 'dfh' ? 12 : 0
|
78
|
+
return [@scores == 'dfh' ? 12 : 0, @scores == 'dfa' ? 12 : 0] if @scores.is_a? String
|
79
79
|
@winner == 0 || @winner == 1 ? complete_match_points : incomplete_match_points
|
80
80
|
end
|
81
81
|
|
data/spec/tennis_spec.rb
CHANGED
@@ -67,6 +67,10 @@ describe Tennis, "#scores" do
|
|
67
67
|
expect(score.winner).to eq :error
|
68
68
|
end
|
69
69
|
|
70
|
+
it "finds the winner properly in scores with 7-5" do
|
71
|
+
score = Tennis.new("3-6,5-7")
|
72
|
+
expect(score.winner).to eq 1
|
73
|
+
end
|
70
74
|
end
|
71
75
|
|
72
76
|
describe Tennis, "#points" do
|
@@ -104,6 +108,11 @@ describe Tennis, "#points" do
|
|
104
108
|
score = Tennis.new("")
|
105
109
|
expect(score.points).to eq [0,0]
|
106
110
|
end
|
111
|
+
|
112
|
+
it "finds the points properly in scores with 7-5" do
|
113
|
+
score = Tennis.new("3-6,5-7")
|
114
|
+
expect(score.points).to eq [8,14]
|
115
|
+
end
|
107
116
|
end
|
108
117
|
|
109
118
|
describe Tennis, "#as_string" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tennis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rohan Katyal
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-02-
|
12
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|