Class: Quandl::Strategy::Strategize

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Strategize

Returns a new instance of Strategize.



38
39
40
41
42
# File 'lib/quandl/strategy.rb', line 38

def initialize(attrs)
  attrs = attrs.clone if attrs.respond_to?(:clone)
  self.attributes = attrs
  self.perform if respond_to?(:perform)
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



32
33
34
# File 'lib/quandl/strategy.rb', line 32

def attributes
  @attributes
end

Class Method Details

.call(attrs) ⇒ Object



34
35
36
# File 'lib/quandl/strategy.rb', line 34

def self.call(attrs)
  self.new(attrs).attributes
end

.define_attributes(*names) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/quandl/strategy.rb', line 44

def self.define_attributes(*names)
  names.each do |name|
    # getter
    define_method(name) do
      self.attributes[name.to_sym]
    end
    # setter
    define_method("#{name}=") do |value|
      self.attributes[name.to_sym] = value
    end
    # present?
    define_method("#{name}?") do
      self.attributes[name.to_sym].present?
    end
  end
end