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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rps_gem.rb +7 -17
  3. data/lib/rps_gem_man +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82b253036f3b10a8ba14e20c29dd106aef8d5fde
4
- data.tar.gz: 1751a793f57de75fcc7482a9b7f30802785f2fd3
3
+ metadata.gz: 11f76ae5b032cf0a800740144b81c009ceb4446a
4
+ data.tar.gz: e2cff67c8f76727003b298b94faa5ce81a03f41f
5
5
  SHA512:
6
- metadata.gz: 62c091fd765032433035351d9eaf0f38aa3b0ea3e8c1267946120282646ecabb833e899a7d837b57d64557c886861ad28e26b655a9a9174456d8aa226b52fdf7
7
- data.tar.gz: c20bfbc1c0f0a03d2b80763e791e4b88676aa5a3d0d19dc2a825cec1dee3df1eb7412acf38005f4adaa5ec9781892c4a1c2f9b0ca3be77314ecf97d56de2bfc6
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
- "Invalid Choice :P"
9
- else
10
- if(options[computer_choice]==options[player_choice])
11
- "Tie!"
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(p1, p2)
24
- wins = {rock: :scissors, scissors: :paper, paper: :rock}
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
@@ -1,4 +1,4 @@
1
- .TH man 1 "16 Dec 2014" "1.0.1" "Let's Play RPS"
1
+ .TH man 1 "16 Dec 2014" "1.0.2" "Let's Play RPS"
2
2
  .SH NAME
3
3
  play-rps \- Gem to play Command-line Rock, Paper and Scissors game
4
4
  .SH SYNOPSIS
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.1
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@codebrama.com
15
+ - balram@codebrahma.com
16
16
  executables:
17
17
  - play-rps
18
18
  extensions: []