Class: GeneGenie::TemplateEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/gene_genie/template_evaluator.rb

Overview

A Template Evaluator provides certain analysis and useful information about templates

Since:

  • 0.0.2

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ TemplateEvaluator

Returns a new instance of TemplateEvaluator.

Since:

  • 0.0.2



6
7
8
# File 'lib/gene_genie/template_evaluator.rb', line 6

def initialize(template)
  @template = template
end

Instance Method Details

#permutationsObject

Since:

  • 0.0.2



10
11
12
13
14
# File 'lib/gene_genie/template_evaluator.rb', line 10

def permutations
  @permutations ||= @template.map { |hash|
    hash.map { |_, v| v.size }.reduce(:*)
  }.reduce(:*)
end

returns a minimum of 10 unless the total number of permutations is below that otherwise, returns 1/1000th of the number of permutations up to a maximum of 1000

Since:

  • 0.0.2



20
21
22
23
24
25
# File 'lib/gene_genie/template_evaluator.rb', line 20

def recommended_size
  [
    [(permutations / 100_000), 5000].min,
    [10, permutations].min,
  ].max
end