frankfurter/lib/currency.rb

25 lines
389 B
Ruby
Raw Normal View History

2012-11-20 17:36:12 +01:00
class Currency < Sequel::Model
2015-08-30 11:36:32 +02:00
dataset_module do
def recent
order(Sequel.desc(:date))
end
def before(value)
where { date <= value }
end
def current_date
currency = recent.first
currency.date if currency
end
def current_date_before(value)
before(value).current_date
end
2012-11-20 17:36:12 +01:00
end
2015-08-31 11:56:01 +02:00
def to_h
2012-11-20 17:36:12 +01:00
{ iso_code => rate }
end
end