omw_random_string 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/omw_random_string.rb +22 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c0d9b069ad8c43702d9a79230326c3862482210
4
+ data.tar.gz: 45339719a3b6f70b9164d7b8c9a72d52e7c4bd04
5
+ SHA512:
6
+ metadata.gz: f90acbc99d890e4876c71511b1de8afd2da6499bed8e0cb2e99c6d8395d33c930cefaae1f197809a3bc1d3592a464a5037015c9a9db4ff19f6cc666308dfb9c0
7
+ data.tar.gz: bab8f37ce04b4cac8deb05b218c57b7b40bc6f8786e86e680384440c5c7a4b9b5a1c3dbd1171df1ef88836c6571323d01b111c0ca8933ac46e41718eb74b6a35
@@ -0,0 +1,22 @@
1
+ class OmwRandomString
2
+ def self.generate(length = 16)
3
+ # allowed_chars contains the characters to be used by the generator
4
+ allowed_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
5
+
6
+ # Contains the new random string
7
+ random_string = ""
8
+
9
+ # set seed for random number to time
10
+ srand Time.now.to_i
11
+
12
+ # lookup char given the random number as position of the char
13
+ # add new char to random_string var
14
+ # This is exectude 'length' times
15
+ for i in 1..length do
16
+ random_string += allowed_chars[rand(allowed_chars.length)]
17
+ end
18
+
19
+ # return the random_string so it can be used in your code
20
+ return random_string
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omw_random_string
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gwen De Brul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Generate a random string with a specified length of chars
14
+ email: gwen@debrul.be
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/omw_random_string.rb
20
+ homepage: http://rubygems.org/gems/omw_random_string
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.4.8
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A random string generator
44
+ test_files: []