Class: MimiCheck::Generator::SuchThat
- Inherits:
-
Object
- Object
- MimiCheck::Generator::SuchThat
- Extended by:
- TailCallOptimization
- Includes:
- MimiCheck::Generator
- Defined in:
- lib/mimicheck/generator/such_that.rb
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(generator, predicate = nil, &blk) ⇒ SuchThat
constructor
A new instance of SuchThat.
Methods included from TailCallOptimization
Methods included from MimiCheck::Generator
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
#generate ⇒ Object
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 |