hangman_letter_check 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/hangman_letter_check.rb +16 -0
  2. metadata +48 -0
@@ -0,0 +1,16 @@
1
+ class String
2
+ # Searches the String and returns an array of all the locations where the letter(s) occurs
3
+ def occurrences(search_letter)
4
+ occurrences = []
5
+ idx = 0
6
+
7
+ self.each_char do |letter|
8
+ if search_letter == letter.upcase || search_letter == letter.downcase
9
+ occurrences << idx
10
+ end
11
+ idx += 1
12
+ end
13
+
14
+ return occurrences
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hangman_letter_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Antonio Bethune
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-01-05 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple hangman letter checker
15
+ email: abethune96@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/hangman_letter_check.rb
21
+ homepage:
22
+ licenses:
23
+ - MIT
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 1.8.24
43
+ signing_key:
44
+ specification_version: 3
45
+ summary: Checks to see if the letter given occur in the word to be guessed and returns
46
+ the indexes of the letter if it does
47
+ test_files: []
48
+ has_rdoc: