Class: Ab::Indexer::Randomizer::OneEight

Inherits:
Object
  • Object
show all
Defined in:
lib/ab/indexer.rb

Instance Method Summary collapse

Constructor Details

#initialize(seed) ⇒ OneEight

Returns a new instance of OneEight.



59
60
61
# File 'lib/ab/indexer.rb', line 59

def initialize(seed)
  srand(seed)
end

Instance Method Details

#rand(value) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/ab/indexer.rb', line 63

def rand(value)
  if value.kind_of?(Range)
    first = value.first
    last = value.last - first
    return Kernel::rand(last) + first
  else
    Kernel::rand(value)
  end
end