Class: Quandl::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/quandl/strategy.rb

Defined Under Namespace

Classes: Strategize

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Strategy

Returns a new instance of Strategy.



5
6
7
# File 'lib/quandl/strategy.rb', line 5

def initialize(*args, &block)
  setup(*args, &block)
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/quandl/strategy.rb', line 3

def attributes
  @attributes
end

Instance Method Details

#classesObject



26
27
28
# File 'lib/quandl/strategy.rb', line 26

def classes
  @classes ||= []
end

#performObject



14
15
16
17
18
19
20
# File 'lib/quandl/strategy.rb', line 14

def perform
  classes.each do |klass|
    strategy = klass.new(attributes)
    self.attributes = strategy.attributes
  end
  attributes
end

#setup(attributes, &block) ⇒ Object



9
10
11
12
# File 'lib/quandl/strategy.rb', line 9

def setup(attributes, &block)
  self.attributes = attributes
  block.call(self) if block_given?
end

#use(klass) ⇒ Object



22
23
24
# File 'lib/quandl/strategy.rb', line 22

def use(klass)
  self.classes << klass unless classes.include?(klass)
end