PlayRockPaperScissorsGame 2.2.3 → 2.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 936027de91c13edfc80fe800087739bef31d2bf0
4
- data.tar.gz: e3ffaeb8745823c3063c39c30a0dbc24d3107516
3
+ metadata.gz: 7c1015020d251332e0b2be0db5ac330a37cc46d9
4
+ data.tar.gz: 6dc05775f91dd30253190f37253346dfd4ca761c
5
5
  SHA512:
6
- metadata.gz: 5089d16e2900dcbdcd36c0dd6ab22dcb7fcf1adddd1f08e7dd648078ca73507a465faa5502a52e36232c5a880dde48492b1c7721c9d860eb8eabb9db050acaca
7
- data.tar.gz: d60cf2a95c5cf3d029e475a645a745e08ebad7b9fb38ca9c5f5a90efdc18f8947b14ca10e06f7aa4b985665b1bb6a36695aeb0aad3ef2c051fba032d16ade806
6
+ metadata.gz: 866311fa990c33a9e77772e9c99db464e690e0c8ed78db3559c0b7b2ef061a004060f71fe87f468e4f6b60b242067225befa3430853a47bf6182e74498e235c0
7
+ data.tar.gz: f3986f9fe53c3dc4adf444a664582a704cda75f307cdd3c18a7e01c32f4997808c50770b8c0ab0220e4f620dfee283e27a30bb8e2d2c854cc70d23e047f8cc30
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -11,12 +11,13 @@
11
11
 
12
12
  class PlayRockPaperScissorsGame
13
13
 
14
+ # intiate the colorize gem
14
15
  require "colorized_string"
15
16
  ColorizedString.colors
16
17
  ColorizedString.modes
17
18
 
18
19
  module Constants
19
- protected
20
+ protected # make constants protected
20
21
  NTRY_TO_SYM = { 'p' => :PAPER, 'r' => :ROCK, 's' => :SCISSORS }
21
22
  VALID_ENTRIES = NTRY_TO_SYM.keys
22
23
  COMPUTER_CHOICES = NTRY_TO_SYM.values
@@ -26,10 +27,10 @@ class PlayRockPaperScissorsGame
26
27
  end
27
28
 
28
29
  class << self
29
- def continue(str1, str2, str3)
30
+ def continue(str1,str2,str3) # pass in 3 parameters
30
31
  puts ColorizedString[str1].colorize(:color => :green)
31
32
  print ColorizedString[str2].colorize(:color => :green)
32
- gets
33
+ gets # press enter or return to continue
33
34
  puts ColorizedString[str3].colorize(:color => :green)
34
35
  end
35
36
  end
@@ -42,7 +43,7 @@ class PlayRockPaperScissorsGame
42
43
  puts ColorizedString["Player score: #{@player_score}, "].colorize(:blue) +
43
44
  ColorizedString["Computer score: #{@computer_score}, Ties: #{@ties}"].colorize(:blue)
44
45
  player = PrivateMethods.player_choice
45
- computer = Constants::COMPUTER_CHOICES.sample
46
+ computer = Constants::COMPUTER_CHOICES.sample # chooses a random option
46
47
  puts ColorizedString["\nPlayer chooses #{player.to_s.downcase}"].colorize(:blue)
47
48
  puts ColorizedString["Computer chooses #{computer.to_s.downcase}"].colorize(:blue)
48
49
  case PrivateMethods.player_outcome [player, computer]
@@ -81,6 +82,13 @@ class PlayRockPaperScissorsGame
81
82
  elsif choice != Constants::VALID_ENTRIES
82
83
  puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:green)
83
84
  end
85
+ # # one may also do this:
86
+ # case
87
+ # when Constants::NTRY_TO_SYM.key?(choice)
88
+ # return Constants::NTRY_TO_SYM[choice]
89
+ # when choice != Constants::VALID_ENTRIES
90
+ # puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:green)
91
+ # end
84
92
  end
85
93
  end
86
94
  def player_outcome(plays)
data/bin/rps CHANGED
@@ -81,6 +81,13 @@ class PlayRockPaperScissorsGame
81
81
  elsif choice != Constants::VALID_ENTRIES
82
82
  puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:green)
83
83
  end
84
+ # # one may also do this:
85
+ # case
86
+ # when Constants::NTRY_TO_SYM.key?(choice)
87
+ # return Constants::NTRY_TO_SYM[choice]
88
+ # when choice != Constants::VALID_ENTRIES
89
+ # puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:green)
90
+ # end
84
91
  end
85
92
  end
86
93
  def player_outcome(plays)
@@ -7,13 +7,19 @@ module PrivateMethods
7
7
  def player_choice
8
8
  loop do
9
9
  print ColorizedString["Choose rock (r), paper (p) or scissors (s): "].colorize(:green)
10
- choice = gets.chomp.downcase
11
-
10
+ choice = gets.chomp.downcasec
12
11
  if Constants::NTRY_TO_SYM.key?(choice)
13
12
  return Constants::NTRY_TO_SYM[choice]
14
13
  elsif choice != Constants::VALID_ENTRIES
15
14
  puts ColorizedString["That entry is invalid. Please re-enter"].colorize(:green)
16
15
  end
16
+ # # one may also do this:
17
+ # case
18
+ # when Constants::NTRY_TO_SYM.key?(choice)
19
+ # return Constants::NTRY_TO_SYM[choice]
20
+ # when choice != Constants::VALID_ENTRIES
21
+ # puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:green)
22
+ # end
17
23
  end
18
24
  end
19
25
  def player_outcome(plays)
data/lib/rps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PlayRockPaperScissorsGame
2
- VERSION = "2.2.3"
2
+ VERSION = "2.2.4"
3
3
  end
data/rps.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "PlayRockPaperScissorsGame"
3
- spec.version = "2.2.3"
3
+ spec.version = "2.2.4"
4
4
  spec.date = "2017-04-04"
5
5
  spec.summary = "A Rock Paper Scissors Ruby Gem"
6
6
  spec.description = <<-EOF
data/test/test_rps.rb CHANGED
@@ -77,6 +77,13 @@ class RakeTest # create test
77
77
  elsif choice != Constants::VALID_ENTRIES
78
78
  puts ColorizedString["That entry is invalid. Please re-enter"].colorize(:green)
79
79
  end
80
+ # # one may also do this:
81
+ # case
82
+ # when Constants::NTRY_TO_SYM.key?(choice)
83
+ # return Constants::NTRY_TO_SYM[choice]
84
+ # when choice != Constants::VALID_ENTRIES
85
+ # puts ColorizedString["That entry is invalid. Please re-enter."].colorize(:green)
86
+ # end
80
87
  end
81
88
  end
82
89
  def player_outcome(plays)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: PlayRockPaperScissorsGame
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - bag3318
metadata.gz.sig CHANGED
Binary file