Class: MimiCheck::Generator::SuchThat

Inherits:
Object
  • Object
show all
Extended by:
TailCallOptimization
Includes:
MimiCheck::Generator
Defined in:
lib/mimicheck/generator/such_that.rb

Instance Method Summary collapse

Methods included from TailCallOptimization

tail_recursive

Methods included from MimiCheck::Generator

#call, #to_proc

Constructor Details

#initialize(generator, predicate = nil, &blk) ⇒ SuchThat

Returns a new instance of SuchThat.



7
8
9
10
# File 'lib/mimicheck/generator/such_that.rb', line 7

def initialize(generator, predicate = nil, &blk)
  @generator = generator
  @predicate = predicate || blk
end

Instance Method Details

#generateObject



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

def generate
  result = generator.call
  return result if predicate.call(result)
  generate
end