Sha256: 88dc2d8228f827b3f4928ac89cde63bc1c8c0bf46e30fe59cf715dc00f10e7b8

Contents?: true

Size: 692 Bytes

Versions: 1

Compression:

Stored size: 692 Bytes

Contents

require 'singleton'

module Cabalist
  
  class Manager
    
    include Singleton
    attr_accessor :classifiers
  
    def initialize() self.classifiers = [] end
  
  
    def self.register_classifier(klass, proc)
      instance.classifiers << { :klass => klass, :proc => proc }
    end

    def self.setup!
      instance.classifiers.each do |classifier|
        classifier[:klass].const_set( 'CABALIST_CLASSIFIER', 
                                      classifier[:proc].call )
        classifier[:klass].class_eval do
          def classify() CABALIST_CLASSIFIER.eval(self.get_signals) end
          def classify!() set_category(classify) end
        end
      end
    end
  
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cabalist-0.0.1 lib/cabalist/manager.rb