Class: Quotr::YahooParser

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

Class Method Summary collapse

Class Method Details

.parse(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/quotr/yahoo_parser.rb', line 6

def self.parse(data)
  result = {}
  CSV.parse(data, :headers => true) do |row|
    date = Date.strptime(row['Date'], '%Y-%m-%d')
    result[date] = BigDecimal(row['Close'])
  end

  # return results sorted by date descending
  Hash[result.sort.reverse]
end