rps_gem 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rps_gem.rb +7 -17
- data/lib/rps_gem_man +1 -1
- 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: 11f76ae5b032cf0a800740144b81c009ceb4446a
|
|
4
|
+
data.tar.gz: e2cff67c8f76727003b298b94faa5ce81a03f41f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb686b5c491f0c8326139d5431407f20b8e268fc65867add84c46bcd6a9eba887cf6e04bcd2909e05e442fc4a8d56bd9366f8bb3c69196abe996220556034e7d
|
|
7
|
+
data.tar.gz: 4da77d2178e7c43f29777b84be5fef14a0588f62505dda0d385a2dd5eb6a7f9bd918ab4376a9e68e430e19a0d4b6eaca19e9e696a46a707f8df6320a6dfb8f69
|
data/lib/rps_gem.rb
CHANGED
|
@@ -4,25 +4,15 @@ module RpsGem
|
|
|
4
4
|
options = ["rock","paper","scissors"]
|
|
5
5
|
player_choice = options.find_index {|choice| choice.match(/^#{player_op.downcase}/)}
|
|
6
6
|
computer_choice = rand(options.length)
|
|
7
|
-
if player_choice.nil?
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
else
|
|
13
|
-
puts "Computer played #{options[computer_choice]}"
|
|
14
|
-
if(self.winner(options[player_choice], options[computer_choice])==options[player_choice])
|
|
15
|
-
"You Won!"
|
|
16
|
-
else
|
|
17
|
-
"You Loose!"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
7
|
+
return "Invalid Choice :P" if player_choice.nil?
|
|
8
|
+
return "Tie!" if options[computer_choice]==options[player_choice]
|
|
9
|
+
puts "Computer played #{options[computer_choice]}"
|
|
10
|
+
return "You Won!" if self.winner(options[player_choice], options[computer_choice])
|
|
11
|
+
"You Loose!"
|
|
21
12
|
end
|
|
22
13
|
|
|
23
|
-
def winner(
|
|
24
|
-
|
|
25
|
-
{true => p1, false => p2}[wins[p1] == p2]
|
|
14
|
+
def winner(user, comp)
|
|
15
|
+
["rockscissors", "scissorspaper", "paperrock"].include?(user+comp)
|
|
26
16
|
end
|
|
27
17
|
|
|
28
18
|
def self.example
|
data/lib/rps_gem_man
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rps_gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Balram
|
|
@@ -12,7 +12,7 @@ date: 2014-12-16 00:00:00.000000000 Z
|
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
15
|
-
- balram@
|
|
15
|
+
- balram@codebrahma.com
|
|
16
16
|
executables:
|
|
17
17
|
- play-rps
|
|
18
18
|
extensions: []
|