Class: Cabalist::Manager

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/cabalist/manager.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManager

Returns a new instance of Manager.



10
# File 'lib/cabalist/manager.rb', line 10

def initialize() self.classifiers = [] end

Instance Attribute Details

#classifiersObject

Returns the value of attribute classifiers.



8
9
10
# File 'lib/cabalist/manager.rb', line 8

def classifiers
  @classifiers
end

Class Method Details

.register_classifier(klass, proc) ⇒ Object



13
14
15
# File 'lib/cabalist/manager.rb', line 13

def self.register_classifier(klass, proc)
  instance.classifiers << { :klass => klass, :proc => proc }
end

.setup!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/cabalist/manager.rb', line 17

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