Class: RandomlyGenerated::Object
- Inherits:
-
Object
- Object
- RandomlyGenerated::Object
- Defined in:
- lib/randomly_generated/object.rb
Overview
This is the base class for all classes used to generate random objects.
Instance Attribute Summary collapse
-
#rand ⇒ Object
readonly
Returns the value of attribute rand.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
-
#call ⇒ Object
Returns the generated object.
-
#initialize(options = {}) ⇒ Object
constructor
A new instance of Object.
-
#shrunken_subsets ⇒ Object
Returns an array of “shrunken” proper subsets of the object.
Constructor Details
#initialize(options = {}) ⇒ Object
Returns a new instance of Object.
6 7 8 9 |
# File 'lib/randomly_generated/object.rb', line 6 def initialize(={}) @seed = .fetch(:seed) { Random.new_seed } @rand = Random.new(seed) end |
Instance Attribute Details
#rand ⇒ Object (readonly)
Returns the value of attribute rand.
4 5 6 |
# File 'lib/randomly_generated/object.rb', line 4 def rand @rand end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
3 4 5 |
# File 'lib/randomly_generated/object.rb', line 3 def seed @seed end |
Instance Method Details
#call ⇒ Object
Returns the generated object.
12 13 14 |
# File 'lib/randomly_generated/object.rb', line 12 def call raise NotImplementedError end |
#shrunken_subsets ⇒ Object
Returns an array of “shrunken” proper subsets of the object. These subsets are intended to find simpler cases that will reproduce a test failure. WARNING: This API will likely change. We plan to experiment with it heavily. One idea is to have it take a block instead, and pass the various subsets to the block.
20 21 22 23 |
# File 'lib/randomly_generated/object.rb', line 20 def shrunken_subsets # By default, assume that the object is atomic and cannot be simplified. [] end |