codes_against_humanity 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82958671f5dd4db8b7b0124d17cacf65f5170f24
4
+ data.tar.gz: 60d773369eba86d777104d4ba40ee06052356ff1
5
+ SHA512:
6
+ metadata.gz: c43e1d5d26354a826148df63c22c810bea89f2d46963b57e0c180658dae7f794b905635dbf6e4a9281db9cd3c4534239a16c16b5125fad0f0942f8cc65957198
7
+ data.tar.gz: 5489b42868225dc6cf2e9261a3d7db1b4414c6cb649e27935247ace69d74a1daa95d8c448870b5b4cedd543907ee396993261fee4654cd9737c918eed05d8ce5
@@ -0,0 +1,10 @@
1
+ require 'string_picker'
2
+ class CodesAgainstHumanity
3
+ def self.start
4
+ sp = StringPicker.new
5
+ puts sp.ask_user
6
+ puts sp.reply
7
+ end
8
+ start
9
+ end
10
+
@@ -0,0 +1,66 @@
1
+ class StringPicker
2
+
3
+ NUM_OPTIONS = 4
4
+ NUM_STRINGS = 5
5
+
6
+ def ask_user
7
+ options = generate_options
8
+ print_options(options)
9
+ puts "Choose sentence"
10
+ input = gets
11
+ while !(1..NUM_OPTIONS).to_a.include?(input.chomp.to_i)
12
+ puts "Try again"
13
+ input = gets
14
+ end
15
+ options[input]
16
+ end
17
+
18
+ def reply
19
+ choose_random_string(:replies)
20
+ end
21
+
22
+ private
23
+
24
+ def print_options(options)
25
+ for i in options do
26
+ puts "#{options.index(i)+1}: #{i}"
27
+ end
28
+ end
29
+
30
+ def generate_options
31
+ options = Array.new
32
+ options[0] = choose_random_string(:inputs)
33
+ for i in 1...NUM_OPTIONS-1 do
34
+ loop do
35
+ options[i] = choose_random_string(:inputs)
36
+ break if options.count(options[i]) < 2
37
+ end
38
+ end
39
+ options
40
+ end
41
+
42
+ def choose_random_string(type)
43
+ string_index = rand(0..NUM_STRINGS-1)
44
+ strings[type][string_index]
45
+ end
46
+
47
+ def strings
48
+ {
49
+ :inputs => [
50
+ "Today, I will bake a ____",
51
+ "I ran over a ____ last week",
52
+ "Draw the ____ like one of your French girls",
53
+ "I have had it with these mother----- ____s on this mother----- plane",
54
+ "Hasta la vista, ____"
55
+ ],
56
+
57
+ :replies => [
58
+ "Horse",
59
+ "Flying Spaghetti Monster",
60
+ "Bob Marley",
61
+ "Cultural imperative",
62
+ "Butler"
63
+ ]
64
+ }
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: codes_against_humanity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Melvin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Allows user to pick from a list of strings, then provides a random reply
14
+ email: ''
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/codes_against_humanity.rb
20
+ - lib/string_picker.rb
21
+ homepage: http://rubygems.org/gems/codes_against_humanity
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A practice gem
45
+ test_files: []
46
+ has_rdoc: