Module: RushCheck::RandomGen

Included in:
StdGen, TheStdGen
Defined in:
lib/rushcheck/random.rb

Overview

The module RandomGen is an abstract module. This is included to add instance methods. The author considers that few developers need to read this implementation. See StdGen as an example. Check also Haskell’s System.Random library.

Instance Method Summary collapse

Instance Method Details

#gen_nextObject

gen_next should be overrided as an instance method. It is assumed that gen_next returns an array with length 2. Here, call ‘Foo’ the class which includes RandomGen. The first components of the result should be an integer, and the last components should be an object which belongs to the class Foo.



27
28
29
# File 'lib/rushcheck/random.rb', line 27

def gen_next
  raise_not_implemented_error
end

#gen_rangeObject

gen_range should be overrided as an instance method. It is assumed that split returns an array with length 2. Here, call ‘Foo’ the class which includes RandomGen. Then the components of the result are integers where the first components should be the lowest bound of the first components of gen_next. Another should be the highest bound of the first components of gen_next.



47
48
49
# File 'lib/rushcheck/random.rb', line 47

def gen_range
  raise_not_implemented_error
end

#splitObject

split should be overrided as an instance method. It is assumed that split returns an array with length 2. Here, call ‘Foo’ the class which includes RandomGen. Then the components of the result are objects which belongs to the class Foo.



36
37
38
# File 'lib/rushcheck/random.rb', line 36

def split
  raise_not_implemented_error
end