Class: Starter::Random::UniformSequence

Inherits:
Sequence
  • Object
show all
Defined in:
lib/starter/random.rb

Instance Attribute Summary collapse

Attributes inherited from Sequence

#generator

Instance Method Summary collapse

Methods inherited from Sequence

random_pool_seed, random_seed, serial_count

Constructor Details

#initialize(opt = {}) ⇒ UniformSequence

Returns a new instance of UniformSequence.



102
103
104
105
106
107
# File 'lib/starter/random.rb', line 102

def initialize opt = {}
  super
  @min = Float(opt[:min] || 0)
  @max = Float(opt[:max] || 1)
  @delta = @max - @min
end

Instance Attribute Details

#maxObject (readonly)

Returns the value of attribute max.



100
101
102
# File 'lib/starter/random.rb', line 100

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



100
101
102
# File 'lib/starter/random.rb', line 100

def min
  @min
end

Instance Method Details

#nextObject



109
110
111
# File 'lib/starter/random.rb', line 109

def next
  @min + @delta*super
end