Class: RandomSet::Template Private
- Inherits:
-
Object
- Object
- RandomSet::Template
- Defined in:
- lib/random_set/template.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #generators ⇒ Object readonly private
Instance Method Summary collapse
- #count ⇒ Object private
-
#generate(count = self.count) ⇒ Object
private
Generation.
- #hash? ⇒ Boolean private
-
#initialize(templates) ⇒ Template
constructor
private
Initialization & attributes.
Constructor Details
#initialize(templates) ⇒ Template
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialization & attributes
9 10 11 12 |
# File 'lib/random_set/template.rb', line 9 def initialize(templates) @hash = templates.is_a?(Hash) @generators = resolve_generators(templates) end |
Instance Attribute Details
#generators ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/random_set/template.rb', line 18 def generators @generators end |
Instance Method Details
#count ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 |
# File 'lib/random_set/template.rb', line 20 def count max = nil generators.each do |_key, generator| next unless generator && generator.respond_to?(:count) max = [ max.to_i, generator.count ].max end max end |
#generate(count = self.count) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generation
32 33 34 35 36 37 38 |
# File 'lib/random_set/template.rb', line 32 def generate(count = self.count) raise CannotInferCount, "no count was specified or could be inferred" unless count data = [] count.times.each { data << generate_next(data) } data end |
#hash? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/random_set/template.rb', line 14 def hash? @hash end |