Class: Fsxtrader::QuoteParser
- Inherits:
-
Object
- Object
- Fsxtrader::QuoteParser
- Defined in:
- lib/fsxtrader/quote_parser.rb
Instance Attribute Summary collapse
-
#quotes ⇒ Object
Returns the value of attribute quotes.
Instance Method Summary collapse
-
#initialize(symbols) ⇒ QuoteParser
constructor
A new instance of QuoteParser.
- #parse ⇒ Object
Constructor Details
#initialize(symbols) ⇒ QuoteParser
Returns a new instance of QuoteParser.
4 5 6 7 8 |
# File 'lib/fsxtrader/quote_parser.rb', line 4 def initialize(symbols) @url = "http://finance.yahoo.com/d/quotes.csv?s=#{symbols.join('+').upcase}&f=sl1" @raw_csv = open(@url) parse end |
Instance Attribute Details
#quotes ⇒ Object
Returns the value of attribute quotes.
3 4 5 |
# File 'lib/fsxtrader/quote_parser.rb', line 3 def quotes @quotes end |
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/fsxtrader/quote_parser.rb', line 10 def parse @quotes = Hash.new @raw_csv.each_line do |line| #puts "Parsed Yahoo Stock Quote Line: #{line}" line.gsub!('"', '') symbol, price = *line.split(',') @quotes[symbol] = price.to_f end end |