Class: IRXML::Stock::HistoricQuote

Inherits:
Object
  • Object
show all
Defined in:
lib/irxml/stock.rb

Instance Method Summary collapse

Constructor Details

#initialize(lookupdate, ticker = IRXML.company_id) ⇒ HistoricQuote

Returns a new instance of HistoricQuote.



28
29
30
31
# File 'lib/irxml/stock.rb', line 28

def initialize(lookupdate, ticker = IRXML.company_id)
  get(lookupdate, ticker)
  set_values
end

Instance Method Details

#attributesObject



38
39
40
# File 'lib/irxml/stock.rb', line 38

def attributes
  @attributes ||= {}
end

#get(lookupdate, ticker) ⇒ Object



33
34
35
36
# File 'lib/irxml/stock.rb', line 33

def get(lookupdate, ticker)
  lookupdate = CGI::escape(lookupdate.strftime("%m/%d/%Y"))
  @data = IRXML.get('HistoricStockQuote', {'TICKER' => ticker, 'LOOKUPDATE' => lookupdate})
end

#set_valuesObject



42
43
44
45
46
47
# File 'lib/irxml/stock.rb', line 42

def set_values
  @data.css('ROW').children.each do |node|
    attributes[node.name.downcase] = node.content
    self.class.class_eval { define_method(node.name.downcase) { attributes[node.name.downcase] } }
  end
end