Class: Cdigits::Luhn::RandomTable
- Inherits:
-
Object
- Object
- Cdigits::Luhn::RandomTable
- Defined in:
- lib/cdigits/luhn/random_table.rb
Instance Attribute Summary collapse
-
#previsous ⇒ Object
Returns the value of attribute previsous.
Instance Method Summary collapse
-
#initialize(modulus:) ⇒ RandomTable
constructor
A new instance of RandomTable.
-
#pick(exclude: []) ⇒ Integer
pick from number table.
-
#pick_non_zero ⇒ Integer
pick from number table exclude 0.
Constructor Details
#initialize(modulus:) ⇒ RandomTable
Returns a new instance of RandomTable.
8 9 10 11 |
# File 'lib/cdigits/luhn/random_table.rb', line 8 def initialize(modulus:) @modulus = modulus @previsous = nil end |
Instance Attribute Details
#previsous ⇒ Object
Returns the value of attribute previsous.
6 7 8 |
# File 'lib/cdigits/luhn/random_table.rb', line 6 def previsous @previsous end |
Instance Method Details
#pick(exclude: []) ⇒ Integer
pick from number table
22 23 24 |
# File 'lib/cdigits/luhn/random_table.rb', line 22 def pick(exclude: []) table(exclude).sample end |
#pick_non_zero ⇒ Integer
pick from number table exclude 0
15 16 17 |
# File 'lib/cdigits/luhn/random_table.rb', line 15 def pick_non_zero pick(exclude: [0]) end |