string_search 0.0.1

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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/string_search.rb +38 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b6e0a46cc3ecf9d63f3889fe6dc370c5b5074e5
4
+ data.tar.gz: 3d6b8ce739d13aa0133a0c50e59668b8a1c06b99
5
+ SHA512:
6
+ metadata.gz: 540feeac49d67ee9493464cd41b59048ef7718ea3062c7381b94ad4adac89e5c63abb81cb10a1cc6eaada58adce9a2fd771b359b7e21bb5a8e58c33d45608a51
7
+ data.tar.gz: e0e87b23d066c151517544ebf7ef1648c90aec76e9a42dd22c8b5584edaea5efb246bc47ad4974c44f3dde60cac848d69f52234fa2d07f1163acbd5001118831
@@ -0,0 +1,38 @@
1
+ !# /usr/bin/env ruby
2
+ #string_search.rb
3
+
4
+
5
+ def search_me(string, substring)
6
+ len = substring.size
7
+ string_len = string.size
8
+ i = 0
9
+ string_counter = 0
10
+ until string_counter == string_len
11
+ string.chars.each_with_index do |letter, index|
12
+ string_counter += 1
13
+ if string[index, len] == substring
14
+ i += 1
15
+ if i == 1
16
+ sing_or_plural = "match"
17
+ elsif i > 1
18
+ sing_or_plural = "matches"
19
+ end
20
+ print "found #{i} #{sing_or_plural}: #{substring.upcase}"
21
+ true
22
+ end
23
+ end
24
+ if i == 0
25
+ print "no match"
26
+ false
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+ print "enter your string: "
33
+ string = gets.chomp.to_s
34
+ print "enter substring: "
35
+ substring = gets.chomp.to_s
36
+
37
+
38
+ puts search_me(string, substring)
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string_search
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - fookh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: simple search function for user supplied strings
14
+ email: foo@yetispeak.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/string_search.rb
20
+ homepage: http://rubygems.org/gems/string_search
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.2.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: search strings for substrings
44
+ test_files: []