Module: RandomSet

Defined in:
lib/random_set.rb,
lib/random_set/version.rb,
lib/random_set/gaussian.rb,
lib/random_set/template.rb,
lib/random_set/gaussian_trend.rb

Defined Under Namespace

Classes: CannotInferCount, Gaussian, GaussianTrend, Template, UnsupportedTemplate

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.generate([count], template) ⇒ Array

Generates a series of data based on the given template. This template may be a hash or an array. If a hash is given, the output of this function is an array of hashes. Conversely, if an array is given, the output is an array of arrays.

Parameters:

  • count (Fixnum)

    A count. Leave this out if the count can be inferred.

  • template (Hash|Array)

    The generator template.

Returns:

  • (Array)

    The generated data.

Raises:

  • (UnsupportedTemplated)

    If any of the provided templates was not supported.

  • (CannotInferCount)

    If no count was specified, and no count could be inferred.



20
21
22
23
24
# File 'lib/random_set.rb', line 20

def generate(*args)
  raise ArgumentError, "template required" if args.empty?
  raise ArgumentError, "too many arguments (1..2 expected)" if args.length > 2
  Template.new(args.pop).generate *args
end