Class: IRXML::Stock::Quote

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

Instance Method Summary collapse

Constructor Details

#initialize(ticker = IRXML.company_id) ⇒ Quote

Returns a new instance of Quote.



4
5
6
7
# File 'lib/irxml/stock.rb', line 4

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

Instance Method Details

#attributesObject



13
14
15
# File 'lib/irxml/stock.rb', line 13

def attributes
  @attributes ||= {}
end

#get(ticker) ⇒ Object



9
10
11
# File 'lib/irxml/stock.rb', line 9

def get(ticker)
  @data = IRXML.get('StockQuote', 'TICKER' => ticker)
end

#set_valuesObject



17
18
19
20
21
22
# File 'lib/irxml/stock.rb', line 17

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