Class: Quotr::Yahoo

Inherits:
Object
  • Object
show all
Defined in:
lib/quotr/yahoo.rb

Constant Summary collapse

URL =
"http://ichart.finance.yahoo.com/table.csv".freeze
PARAMS =
"s=%s&a=%02d&b=%d&c=%d&d=%02d&e=%d&f=%d&g=d&ignore=.csv".freeze

Class Method Summary collapse

Class Method Details

.fetch(symbol, date) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/quotr/yahoo.rb', line 8

def self.fetch(symbol, date)
  resp = Net::HTTP.get_response(uri(symbol, date - 7, date))     
  if resp.code.to_i == 200
    resp.body
  else
    raise Error.new("Failure retrieving quote for #{symbol} on " +
                    "#{date.to_s}: #{resp.message} (#{resp.code})")
  end
end