Class: MimiCheck::Generator::Float

Inherits:
Object
  • Object
show all
Includes:
MimiCheck::Generator
Defined in:
lib/mimicheck/generator/float.rb

Instance Method Summary collapse

Methods included from MimiCheck::Generator

#call, #to_proc

Constructor Details

#initialize(range = -1e10..1e10) ⇒ Float

Returns a new instance of Float.



6
7
8
9
# File 'lib/mimicheck/generator/float.rb', line 6

def initialize(range = -1e10..1e10)
  @min = range.min
  @max = range.max
end

Instance Method Details

#generateObject



14
15
16
17
# File 'lib/mimicheck/generator/float.rb', line 14

def generate
  fail ArgumentError unless min && max
  Random.rand * (max - min) + min
end