fibonacci_rng 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a508cef0fdf713686d64af287131073ad0bf5ad9
4
- data.tar.gz: 767c9eee52ab193288b848ab9d4ef5090a80ec10
3
+ metadata.gz: 25d369689141fd274fafd28fd4b14a798c820391
4
+ data.tar.gz: 06103171f46180d1c91868a04ea5969d50133148
5
5
  SHA512:
6
- metadata.gz: 08463aeda003dc4e564565df6b6d1532a1d5320a21a9c3ede419a1df052a4ad129eb16770ebf955091e3ea9d69fb94af487ac9386c3f2a36f87cdfb2082feb2f
7
- data.tar.gz: 9b7b32359d8d61a867f6a2f41ec9c29ef7cf221020393ab0321a38930f4140f3a14eaff947e83ce2b03da7a40c0c639e3aeb5dd0b2bb2d38723f21c61ab30f48
6
+ metadata.gz: ec0f2696f35dd28eae03b816472fe345ad92bd15160f2024a44412c64e0772a9f6b5adc4bdc51471539ded28a41985ba3fb780b67ca5533b17a8d98fe8181d9a
7
+ data.tar.gz: 3099c3db8203237954881f73aca21db57d8e0ceaf0f4e89f6fbb81d7c6881f1a0c074d42dd095bef36b738d7ce02e6d5f0d3d65e2339cec0b0430fcf55e05920
data/README.md CHANGED
@@ -59,8 +59,8 @@ seed. Here is an overview of the available options.
59
59
  @my_rng = FibonacciRng.new(FibonacciRng.new_seed, 12) # Random seed, depth = 12
60
60
 
61
61
  ```
62
- In addition, keyword arguments are emulated (as of Version 0.3.1) so these
63
- options also are available:
62
+ In addition, keyword arguments are emulated (as of Version 0.4.0) so these
63
+ additional options also are available:
64
64
 
65
65
  ```ruby
66
66
  #Method #5
@@ -76,7 +76,17 @@ Note: Mixing positional and keyword arguments will not, in general, work.
76
76
 
77
77
  #### Generating Pseudo Random Data
78
78
 
79
- To get some data out here are some options:
79
+ The Fibonacci generator class supports the classical rand method that emulates
80
+ the behavior of the standard generator. It works like this:
81
+
82
+ ```ruby
83
+ @my_rng.rand # A "random" float between 0.0 and less than 1.
84
+ @my_rng.rand(0) # A "random" float between 0.0 and less than 1.
85
+ @my_rng.rand(100) # A "random" integer between 0 and 99
86
+ @my_rng.rand(1..6) # A "random" integer between 1 and 6
87
+ ```
88
+
89
+ In addition, here are some other options:
80
90
 
81
91
  ```ruby
82
92
  @my_rng.dice(100) # A "random" integer between 0 and 99
@@ -2,5 +2,5 @@
2
2
 
3
3
  #The class of Fibonacci inspired random number generators.
4
4
  class FibonacciRng
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
6
6
  end
data/lib/fibonacci_rng.rb CHANGED
@@ -139,12 +139,16 @@ class FibonacciRng
139
139
 
140
140
  #Append data to the generator
141
141
  def <<(data)
142
- data.to_s.each_byte.each do |value|
142
+ str = data.to_s
143
+
144
+ str.each_byte.each do |value|
143
145
  index = @buffer[0] % @depth
144
146
  do_spin
145
147
  @buffer[index] += value
146
148
  do_spin
147
149
  end
150
+
151
+ do_spin if str.empty?
148
152
  end
149
153
 
150
154
  private
@@ -28,6 +28,12 @@ class FibonacciHasherTester < Minitest::Test
28
28
 
29
29
  str = 'j5jqhk7ntrze02icv38gj28efa2qrctr6mi5ejbr2p4nj'
30
30
  assert_equal(str, fib.hash_string)
31
+
32
+ fib << nil
33
+
34
+ refute_equal(str, fib.hash_string)
35
+ str = '1g5sgt443g4jcn3bfpiee1fkqoklo0i1ctkjro2vevpp0'
36
+ assert_equal(str, fib.hash_string)
31
37
  end
32
38
 
33
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fibonacci_rng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest_visible