frankfurter/lib/currency.rb
2017-06-14 23:01:27 +01:00

26 lines
383 B
Ruby

# frozen_string_literal: true
class Currency < Sequel::Model
dataset_module do
def recent
order(Sequel.desc(:date))
end
def before(value)
where { date <= value }
end
def current_date
recent.first&.date
end
def current_date_before(value)
before(value).current_date
end
end
def to_h
{ iso_code => rate }
end
end