Class: Quandl::Strategy
- Inherits:
-
Object
- Object
- Quandl::Strategy
- Defined in:
- lib/quandl/strategy.rb
Defined Under Namespace
Classes: Strategize
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(*args, &block) ⇒ Strategy
constructor
A new instance of Strategy.
- #perform ⇒ Object
- #setup(attributes, &block) ⇒ Object
- #use(klass) ⇒ Object
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
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/quandl/strategy.rb', line 3 def attributes @attributes end |
Instance Method Details
#classes ⇒ Object
26 27 28 |
# File 'lib/quandl/strategy.rb', line 26 def classes @classes ||= [] end |
#perform ⇒ Object
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 |