Module: LFSR
- Defined in:
- lib/lfsr.rb
Defined Under Namespace
Modules: Fast, Pure Classes: Base
Constant Summary collapse
- VERSION =
"1.0.0"
Class Method Summary collapse
- .default_to(namespace) ⇒ Object
-
.gen(max, namespace = LFSR) ⇒ Object
Get a LFSR with the appropriate number of bits to reach the maximum needed.
Class Method Details
.default_to(namespace) ⇒ Object
34 35 36 37 |
# File 'lib/lfsr.rb', line 34 def self.default_to(namespace) 2.upto(61) { |n| remove_const("Size#{n}")} if defined? LFSR::Size2 2.upto(61) { |n| const_set("Size#{n}", namespace.const_get("Size#{n}")) } end |
.gen(max, namespace = LFSR) ⇒ Object
Get a LFSR with the appropriate number of bits to reach the maximum needed.
29 30 31 32 |
# File 'lib/lfsr.rb', line 29 def self.gen(max, namespace = LFSR) bits = Math.log2(max + 2).ceil namespace.const_get("Size#{bits < 3 ? 3 : bits}").new(max) end |