frankfurter/lib/query.rb
Hakan Ensari cfbb4ac4ac Repack app
I'm moving my company's server to a private location now that I have sold the domain. While prepping for this, I've done some cleanup and also threw in changes I had lingering on my hard drive.

- Run a single database query instead of two
- Fold the gem into the app and use Ox instead of REXML
- Simplify error handling logic
- Relax throttling
2018-03-08 23:51:36 +00:00

28 lines
497 B
Ruby

# frozen_string_literal: true
class Query
def initialize(params = {})
@params = params
end
def amount
@params[:amount].to_f if @params[:amount] # rubocop:disable Style/SafeNavigation
end
def base
@params.values_at(:base, :from).compact.first&.upcase
end
def symbols
@params.values_at(:symbols, :to).compact.first&.split(',')
end
def date
@params[:date]
end
def to_h
{ amount: amount, base: base, date: date, symbols: symbols }.compact
end
end