Class: Wallace::Koza::Ephemeral
- Inherits:
-
Object
- Object
- Wallace::Koza::Ephemeral
- Defined in:
- lib/modules/koza/ephemeral.rb
Overview
An ephemeral instance is a special type of terminal symbol which only assumes its value (from a set of possible values) once it is selected. The Ephemeral class is used to store the set of possible values that a given ephemeral instance can take.
It is possible to bias the selection of values by the Ephemeral by using a weighted collection or a distribution.
Parameters:
-
values, the range, set or collection of values instances of the ephemeral can assume.
Instance Method Summary collapse
-
#initialize(values) ⇒ Ephemeral
constructor
Constructs a new Ephemeral.
-
#sample(opts = {}) ⇒ Object
Samples a possible value for this ephemeral.
Constructor Details
#initialize(values) ⇒ Ephemeral
Constructs a new Ephemeral.
Parameters:
-
values, the collection of values that instances of this ephemeral can take.
15 16 17 |
# File 'lib/modules/koza/ephemeral.rb', line 15 def initialize(values) @values = values end |
Instance Method Details
#sample(opts = {}) ⇒ Object
Samples a possible value for this ephemeral.
Parameters:
-
opts, a hash of keyword parameters to this method. -> random, the RNG to use when sampling a value.
24 25 26 |
# File 'lib/modules/koza/ephemeral.rb', line 24 def sample(opts = {}) Wallace::Koza::EphemeralInstance.new(@values.sample) end |