Class: RushCheck::TheStdGen

Inherits:
StdGen
  • Object
show all
Includes:
RandomGen, Singleton
Defined in:
lib/rushcheck/random.rb

Overview

TheStdGen is a singleton class to get the unique random number generator using StdGen. TheStdGen includes ruby’s Singleton module.

Instance Attribute Summary

Attributes inherited from StdGen

#left, #right

Instance Method Summary collapse

Constructor Details

#initializeTheStdGen

Returns a new instance of TheStdGen.



129
130
131
# File 'lib/rushcheck/random.rb', line 129

def initialize
  @gen = RushCheck::StdGen.new
end

Instance Method Details

#gen_nextObject



133
134
135
136
137
# File 'lib/rushcheck/random.rb', line 133

def gen_next
  @gen, result = @gen.split
  
  result.gen_next
end

#gen_rangeObject



150
151
152
# File 'lib/rushcheck/random.rb', line 150

def gen_range
  @gen.gen_range
end

#splitObject



139
140
141
142
143
144
# File 'lib/rushcheck/random.rb', line 139

def split
  result = @gen.split
  @gen = @gen.gen_next[1]

  result
end

#to_sObject



146
147
148
# File 'lib/rushcheck/random.rb', line 146

def to_s
  @gen.to_s
end