frankfurter/lib/currency.rb
2015-08-31 10:56:01 +01:00

25 lines
389 B
Ruby

class Currency < Sequel::Model
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
end
def to_h
{ iso_code => rate }
end
end