Module: Heuristics
- Defined in:
- lib/heuristics.rb,
lib/heuristics/tester.rb,
lib/heuristics/builder.rb,
lib/heuristics/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"2.0.0"
- @@testers =
{}
Class Method Summary collapse
Class Method Details
.define(name = :default, &block) ⇒ Object
10 11 12 13 |
# File 'lib/heuristics.rb', line 10 def define(name = :default, &block) raise "A heuristic with the name '#{name}' already exists" unless @@testers[name].nil? @@testers[name] = Tester.new(Docile.dsl_eval(Builder.new, &block)) end |
.test(value, name = :default) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/heuristics.rb', line 15 def test(value, name = :default) unless @@testers.key? name raise "Heuristic named #{name} hasn't been defined." else @@testers[name].test(value) end end |