Module: YahooStockSplits
- Defined in:
- lib/yahoo_stock_splits.rb,
lib/yahoo_stock_splits/version.rb
Constant Summary collapse
- VERSION =
"1.0.4"
Class Method Summary collapse
Class Method Details
.get(symbol) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/yahoo_stock_splits.rb', line 6 def YahooStockSplits.get(symbol) # Jul 3, 1989 [2:1] re = /(.+)\[(\d+):(\d+)\]/ url = "http://finance.yahoo.com/q/bc?s=#{symbol}+Basic+Chart" doc = Nokogiri::HTML(open(URI.parse(URI.encode(url)))) doc.css("center nobr").inject([]) do |splits, split| md = re.match split splits << [Date.parse(md[1]).strftime('%Y-%m-%d'), md[2].to_i, md[3].to_i] if md end end |