class TimeTurner
Constants
- VERSION
Attributes
big_bang[R]
Returns random time that will act as the epoch for the class instance
@return [Time]
log[R]
Public Class Methods
new(seed)
click to toggle source
Initialize TimeTurner
pseudo-random generator with a seed value
@param [Integer] seed
# File lib/time_turner.rb, line 14 def initialize(seed) @seed = seed @generator = Random.new(seed) @big_bang = Time.at(@generator.rand(0..Time.utc(2420).to_i)) @log = [] end
Public Instance Methods
rand(range = 0.0..1)
click to toggle source
Generates random value within the range provided By default, returns a floating point number between 0 and 1
@param [Range] range
@return [Time]
# File lib/time_turner.rb, line 27 def rand(range = 0.0..1) time = @generator.rand(range) @log << { constraint: range, val: time } time end