noreprand 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/noreprand.rb +28 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a0a495bbadd5217a611030fc570e6156af5c70ec
4
+ data.tar.gz: 3a46150d50b3924dd26a96c60f7289064ac57cd7
5
+ SHA512:
6
+ metadata.gz: 54f1dff3b7eace6831e8ab4f0f476a9278ee063590de6e02fc995e985d5514d936e3578747fd7c87e31d202021ae41767b94f8f584dcd89629a954506bdad6cc
7
+ data.tar.gz: cdbd503e3452cffa793a9a8151f215196298d6eb82766de70ccb649356aebd1401044ec6a1d6d9d1dccd2b53cefaa664799e00155b2a14d158fc2fc133bf9f79
data/lib/noreprand.rb ADDED
@@ -0,0 +1,28 @@
1
+ class ExceededDigitLimit < StandardError
2
+ def initialize(msg = "Exceeded digit limit of 10")
3
+ super
4
+ end
5
+ end
6
+
7
+ def raand(digitcount, nostartwithzero = false)
8
+ if digitcount > 10
9
+ raise ExceededDigitLimit
10
+ else
11
+ digits = Array(0..9)
12
+ tempnum = []
13
+ digitcount.times do
14
+ if tempnum.length == 0 && nostartwithzero == true
15
+ digits.delete(0)
16
+ randindex = rand(digits.length)
17
+ tempnum.push(digits[randindex])
18
+ digits.delete(digits[randindex])
19
+ digits.insert(0, 0)
20
+ else
21
+ randindex = rand(digits.length)
22
+ tempnum.push(digits[randindex])
23
+ digits.delete(digits[randindex])
24
+ end
25
+ end
26
+ return tempnum.join('')
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noreprand
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Tan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple random number generator that doesn't have repeating digits.
14
+ The number of digits can also be specified
15
+ email: jonathantanatlol@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/noreprand.rb
21
+ homepage: https://github.com/peaceknight05/noreprand
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.6.14
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A simple random number generator that doesn't have repeating digits
45
+ test_files: []