RPSrb 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RPSrb.gemspec +1 -1
- data/doc/RockPaperScissors.html +83 -53
- data/doc/created.rid +3 -3
- data/doc/js/navigation.js.gz +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/search_index.js.gz +0 -0
- data/doc/js/searcher.js.gz +0 -0
- data/doc/table_of_contents.html +5 -0
- data/lib/RPSrb/Version.rb +1 -1
- data/lib/RockPaperScissors.rb +1 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc1a734dbecaedd4c28ac3637365e2c60d8a378
|
4
|
+
data.tar.gz: 63fb84eb8f8eeb2c3c9105ef0f96ded6168f29a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74a26d80cb9347fa424a62ce8cebf83f754aa8c5b5c29c80e3808095090f8046d81a945f7e0250c7d7201a78028d165914d88cef580e48c319800d848413ccad
|
7
|
+
data.tar.gz: 9f4fe67b635255d145fee14a305e62afe5483fa1ba33e2e80fd7af91b5c20d3bde16512ce0cbdc4002ebd4eaa9aa8d3f8c0db13bf65c3cd2a17d5c467e87776c
|
data/RPSrb.gemspec
CHANGED
data/doc/RockPaperScissors.html
CHANGED
@@ -71,6 +71,8 @@
|
|
71
71
|
|
72
72
|
<ul class="link-list" role="directory">
|
73
73
|
|
74
|
+
<li ><a href="#method-c-continue">::continue</a>
|
75
|
+
|
74
76
|
<li ><a href="#method-c-new">::new</a>
|
75
77
|
|
76
78
|
<li ><a href="#method-i-final_outcome">#final_outcome</a>
|
@@ -166,6 +168,44 @@
|
|
166
168
|
</header>
|
167
169
|
|
168
170
|
|
171
|
+
<div id="method-c-continue" class="method-detail ">
|
172
|
+
|
173
|
+
<div class="method-heading">
|
174
|
+
<span class="method-name">continue</span><span
|
175
|
+
class="method-args">(str1,str2,str3)</span>
|
176
|
+
|
177
|
+
<span class="method-click-advice">click to toggle source</span>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
|
181
|
+
|
182
|
+
<div class="method-description">
|
183
|
+
|
184
|
+
<h2 id="method-c-continue-label-Define+entry+point+for+game">Define entry point for game<span><a href="#method-c-continue-label-Define+entry+point+for+game">¶</a> <a href="#top">↑</a></span></h2>
|
185
|
+
|
186
|
+
<p>this will provide a game intro</p>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
<div class="method-source-code" id="continue-source">
|
192
|
+
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 41</span>
|
193
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">continue</span>(<span class="ruby-identifier">str1</span>,<span class="ruby-identifier">str2</span>,<span class="ruby-identifier">str3</span>)
|
194
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">str1</span>
|
195
|
+
<span class="ruby-identifier">print</span> <span class="ruby-identifier">str2</span>
|
196
|
+
<span class="ruby-identifier">gets</span>
|
197
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">str3</span>
|
198
|
+
<span class="ruby-keyword">end</span></pre>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
</div>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
</div>
|
207
|
+
|
208
|
+
|
169
209
|
<div id="method-c-new" class="method-detail ">
|
170
210
|
|
171
211
|
<div class="method-heading">
|
@@ -185,7 +225,7 @@
|
|
185
225
|
|
186
226
|
|
187
227
|
<div class="method-source-code" id="new-source">
|
188
|
-
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line
|
228
|
+
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 52</span>
|
189
229
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
|
190
230
|
<span class="ruby-ivar">@player_score</span> = <span class="ruby-ivar">@computer_score</span> = <span class="ruby-ivar">@ties</span> = <span class="ruby-value">0</span>
|
191
231
|
<span class="ruby-keyword">end</span></pre>
|
@@ -207,6 +247,42 @@
|
|
207
247
|
</header>
|
208
248
|
|
209
249
|
|
250
|
+
<div id="method-i-final_outcome" class="method-detail ">
|
251
|
+
|
252
|
+
<div class="method-heading">
|
253
|
+
<span class="method-name">final_outcome</span><span
|
254
|
+
class="method-args">(pl, co)</span>
|
255
|
+
|
256
|
+
<span class="method-click-advice">click to toggle source</span>
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
|
263
|
+
<h2 id="method-i-final_outcome-label-Define+final+outcome+function">Define final outcome function<span><a href="#method-i-final_outcome-label-Define+final+outcome+function">¶</a> <a href="#top">↑</a></span></h2>
|
264
|
+
|
265
|
+
<p>this will determine who wins the whole match in the end</p>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
<div class="method-source-code" id="final_outcome-source">
|
271
|
+
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 116</span>
|
272
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">final_outcome</span>(<span class="ruby-identifier">pl</span>, <span class="ruby-identifier">co</span>)
|
273
|
+
<span class="ruby-keyword">return</span> <span class="ruby-value">:WIN</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pl</span> <span class="ruby-operator">></span> <span class="ruby-identifier">co</span>
|
274
|
+
<span class="ruby-keyword">return</span> <span class="ruby-value">:LOSE</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pl</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">co</span>
|
275
|
+
<span class="ruby-keyword">end</span></pre>
|
276
|
+
</div>
|
277
|
+
|
278
|
+
</div>
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
</div>
|
284
|
+
|
285
|
+
|
210
286
|
<div id="method-i-play" class="method-detail ">
|
211
287
|
|
212
288
|
<div class="method-heading">
|
@@ -222,14 +298,13 @@
|
|
222
298
|
|
223
299
|
<h2 id="method-i-play-label-Define+play+game+method">Define play game method<span><a href="#method-i-play-label-Define+play+game+method">¶</a> <a href="#top">↑</a></span></h2>
|
224
300
|
|
225
|
-
<p>
|
226
|
-
functioonality for this game</p>
|
301
|
+
<p>it will also constain most of the “play” functioonality for this game</p>
|
227
302
|
|
228
303
|
|
229
304
|
|
230
305
|
|
231
306
|
<div class="method-source-code" id="play-source">
|
232
|
-
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line
|
307
|
+
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 58</span>
|
233
308
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">play</span>(<span class="ruby-identifier">winning_score</span>)
|
234
309
|
<span class="ruby-keyword">while</span> <span class="ruby-ivar">@player_score</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">winning_score</span> <span class="ruby-operator">&&</span> <span class="ruby-ivar">@computer_score</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">winning_score</span>
|
235
310
|
<span class="ruby-identifier">puts</span> <span class="ruby-node">"\nPlayer score: #{@player_score}, "</span> <span class="ruby-operator">+</span>
|
@@ -268,51 +343,6 @@ functioonality for this game</p>
|
|
268
343
|
|
269
344
|
|
270
345
|
|
271
|
-
</div>
|
272
|
-
|
273
|
-
|
274
|
-
</section>
|
275
|
-
|
276
|
-
<section id="protected-instance-5Buntitled-5D-method-details" class="method-section">
|
277
|
-
<header>
|
278
|
-
<h3>Protected Instance Methods</h3>
|
279
|
-
</header>
|
280
|
-
|
281
|
-
|
282
|
-
<div id="method-i-final_outcome" class="method-detail ">
|
283
|
-
|
284
|
-
<div class="method-heading">
|
285
|
-
<span class="method-name">final_outcome</span><span
|
286
|
-
class="method-args">(pl, co)</span>
|
287
|
-
|
288
|
-
<span class="method-click-advice">click to toggle source</span>
|
289
|
-
|
290
|
-
</div>
|
291
|
-
|
292
|
-
|
293
|
-
<div class="method-description">
|
294
|
-
|
295
|
-
<h2 id="method-i-final_outcome-label-Define+final+outcome+function">Define final outcome function<span><a href="#method-i-final_outcome-label-Define+final+outcome+function">¶</a> <a href="#top">↑</a></span></h2>
|
296
|
-
|
297
|
-
<p>this method is protected this will determine who wins the whole match in
|
298
|
-
the end</p>
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
<div class="method-source-code" id="final_outcome-source">
|
304
|
-
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 125</span>
|
305
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">final_outcome</span>(<span class="ruby-identifier">pl</span>, <span class="ruby-identifier">co</span>)
|
306
|
-
<span class="ruby-keyword">return</span> <span class="ruby-value">:WIN</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pl</span> <span class="ruby-operator">></span> <span class="ruby-identifier">co</span>
|
307
|
-
<span class="ruby-keyword">return</span> <span class="ruby-value">:LOSE</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">pl</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">co</span>
|
308
|
-
<span class="ruby-keyword">end</span></pre>
|
309
|
-
</div>
|
310
|
-
|
311
|
-
</div>
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
346
|
</div>
|
317
347
|
|
318
348
|
|
@@ -331,13 +361,13 @@ the end</p>
|
|
331
361
|
|
332
362
|
<h2 id="method-i-player_choice-label-Make+player+choice+method">Make player choice method<span><a href="#method-i-player_choice-label-Make+player+choice+method">¶</a> <a href="#top">↑</a></span></h2>
|
333
363
|
|
334
|
-
<p>this
|
364
|
+
<p>this will sanity check the user's choice</p>
|
335
365
|
|
336
366
|
|
337
367
|
|
338
368
|
|
339
369
|
<div class="method-source-code" id="player_choice-source">
|
340
|
-
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line
|
370
|
+
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 92</span>
|
341
371
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">player_choice</span>
|
342
372
|
<span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
|
343
373
|
<span class="ruby-identifier">print</span> <span class="ruby-string">"\nChoose: Rock (r), Paper (p), or Scissors (s): "</span>
|
@@ -376,13 +406,13 @@ the end</p>
|
|
376
406
|
|
377
407
|
<h2 id="method-i-player_outcome-label-Define+player+outcome">Define player outcome<span><a href="#method-i-player_outcome-label-Define+player+outcome">¶</a> <a href="#top">↑</a></span></h2>
|
378
408
|
|
379
|
-
<p>this
|
409
|
+
<p>this defines the round outcome of the game</p>
|
380
410
|
|
381
411
|
|
382
412
|
|
383
413
|
|
384
414
|
<div class="method-source-code" id="player_outcome-source">
|
385
|
-
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line
|
415
|
+
<pre><span class="ruby-comment"># File lib/RockPaperScissors.rb, line 108</span>
|
386
416
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">player_outcome</span>(<span class="ruby-identifier">plays</span>)
|
387
417
|
<span class="ruby-keyword">return</span> <span class="ruby-value">:WIN</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">WINNERS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">plays</span>)
|
388
418
|
<span class="ruby-keyword">return</span> <span class="ruby-value">:LOSE</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">LOSERS</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">plays</span>)
|
data/doc/created.rid
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Tue, 12 Dec 2017
|
1
|
+
Tue, 12 Dec 2017 11:15:03 -0800
|
2
2
|
lib/exec.rb Tue, 12 Dec 2017 09:59:08 -0800
|
3
|
-
lib/RockPaperScissors.rb Tue, 12 Dec 2017
|
4
|
-
lib/RPSrb/Version.rb Tue, 12 Dec 2017 10:
|
3
|
+
lib/RockPaperScissors.rb Tue, 12 Dec 2017 11:14:21 -0800
|
4
|
+
lib/RPSrb/Version.rb Tue, 12 Dec 2017 10:10:48 -0800
|
data/doc/js/navigation.js.gz
CHANGED
Binary file
|
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["rpsrb","rockpaperscissors","final_outcome()","new()","play()","player_choice()","player_outcome()"],"longSearchIndex":["rpsrb","rockpaperscissors","rockpaperscissors#final_outcome()","rockpaperscissors::new()","rockpaperscissors#play()","rockpaperscissors#player_choice()","rockpaperscissors#player_outcome()"],"info":[["RPSrb","","RPSrb.html","","<p>RubyGems version constant\n<p>this is required for all rubygem packages\n"],["RockPaperScissors","","RockPaperScissors.html","",""],["final_outcome","RockPaperScissors","RockPaperScissors.html#method-i-final_outcome","(pl, co)","<p>Define final outcome function\n<p>this
|
1
|
+
var search_data = {"index":{"searchIndex":["rpsrb","rockpaperscissors","continue()","final_outcome()","new()","play()","player_choice()","player_outcome()"],"longSearchIndex":["rpsrb","rockpaperscissors","rockpaperscissors::continue()","rockpaperscissors#final_outcome()","rockpaperscissors::new()","rockpaperscissors#play()","rockpaperscissors#player_choice()","rockpaperscissors#player_outcome()"],"info":[["RPSrb","","RPSrb.html","","<p>RubyGems version constant\n<p>this is required for all rubygem packages\n"],["RockPaperScissors","","RockPaperScissors.html","",""],["continue","RockPaperScissors","RockPaperScissors.html#method-c-continue","(str1,str2,str3)","<p>Define entry point for game\n<p>this will provide a game intro\n"],["final_outcome","RockPaperScissors","RockPaperScissors.html#method-i-final_outcome","(pl, co)","<p>Define final outcome function\n<p>this will determine who wins the whole match in the end\n"],["new","RockPaperScissors","RockPaperScissors.html#method-c-new","()","<p>Define constructor for class\n"],["play","RockPaperScissors","RockPaperScissors.html#method-i-play","(winning_score)","<p>Define play game method\n<p>it will also constain most of the “play” functioonality for this game …\n"],["player_choice","RockPaperScissors","RockPaperScissors.html#method-i-player_choice","()","<p>Make player choice method\n<p>this will sanity check the user's choice\n"],["player_outcome","RockPaperScissors","RockPaperScissors.html#method-i-player_outcome","(plays)","<p>Define player outcome\n<p>this defines the round outcome of the game\n"]]}}
|
data/doc/js/search_index.js.gz
CHANGED
Binary file
|
data/doc/js/searcher.js.gz
CHANGED
Binary file
|
data/doc/table_of_contents.html
CHANGED
@@ -41,6 +41,11 @@
|
|
41
41
|
<h2 id="methods">Methods</h2>
|
42
42
|
<ul>
|
43
43
|
|
44
|
+
<li class="method">
|
45
|
+
<a href="RockPaperScissors.html#method-c-continue">::continue</a>
|
46
|
+
—
|
47
|
+
<span class="container">RockPaperScissors</span>
|
48
|
+
|
44
49
|
<li class="method">
|
45
50
|
<a href="RockPaperScissors.html#method-c-new">::new</a>
|
46
51
|
—
|
data/lib/RPSrb/Version.rb
CHANGED
data/lib/RockPaperScissors.rb
CHANGED
@@ -37,8 +37,7 @@ class RockPaperScissors
|
|
37
37
|
|
38
38
|
class << self
|
39
39
|
# == Define entry point for game
|
40
|
-
# this
|
41
|
-
private
|
40
|
+
# this will provide a game intro
|
42
41
|
def continue(str1,str2,str3)
|
43
42
|
puts str1
|
44
43
|
print str2
|
@@ -55,9 +54,7 @@ class RockPaperScissors
|
|
55
54
|
end
|
56
55
|
|
57
56
|
# == Define play game method
|
58
|
-
# this method will be public
|
59
57
|
# it will also constain most of the "play" functioonality for this game
|
60
|
-
public
|
61
58
|
def play(winning_score)
|
62
59
|
while @player_score < winning_score && @computer_score < winning_score
|
63
60
|
puts "\nPlayer score: #{@player_score}, " +
|
@@ -91,9 +88,7 @@ class RockPaperScissors
|
|
91
88
|
end
|
92
89
|
|
93
90
|
# == Make player choice method
|
94
|
-
# this method will be protected
|
95
91
|
# this will sanity check the user's choice
|
96
|
-
protected
|
97
92
|
def player_choice
|
98
93
|
loop do
|
99
94
|
print "\nChoose: Rock (r), Paper (p), or Scissors (s): "
|
@@ -109,9 +104,7 @@ class RockPaperScissors
|
|
109
104
|
end
|
110
105
|
|
111
106
|
# == Define player outcome
|
112
|
-
# this method is protected
|
113
107
|
# this defines the round outcome of the game
|
114
|
-
protected
|
115
108
|
def player_outcome(plays)
|
116
109
|
return :WIN if WINNERS.include?(plays)
|
117
110
|
return :LOSE if LOSERS.include?(plays)
|
@@ -119,9 +112,7 @@ class RockPaperScissors
|
|
119
112
|
end
|
120
113
|
|
121
114
|
# == Define final outcome function
|
122
|
-
# this method is protected
|
123
115
|
# this will determine who wins the whole match in the end
|
124
|
-
protected
|
125
116
|
def final_outcome(pl, co)
|
126
117
|
return :WIN if pl > co
|
127
118
|
return :LOSE if pl < co
|