frankfurter/lib/currency.rb

25 lines
392 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
def to_hash
{ iso_code => rate }
end
end