Module: MyExchangeRate
- Defined in:
- lib/my_exchange_rate.rb,
lib/my_exchange_rate/version.rb
Constant Summary collapse
- VERSION =
"0.0.4"
Class Method Summary collapse
Class Method Details
.currency ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/my_exchange_rate.rb', line 7 def self.currency doc= Nokogiri::HTML(open('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml')) @rates=[] doc.xpath('//cube/cube').each do |cube| if cube['currency'] != nil time ="#{ cube.parent['time'] }" currency = "#{ cube['currency'] }" rate = "#{ cube['rate'] }".to_f @rates << [time, currency, rate] end end return @rates end |