class Momm::Storage

Public Instance Methods

client() click to toggle source

Lazy load Client

Returns

Client
# File lib/momm/storage.rb, line 10
def client
  raise NotImplementedError
end
get_rate(currency, date = Date.today) click to toggle source

Fetch the currency rate from client

Parameters

currency

Currency passed in

date

Ruby date type, the date of currency rate, today by default

Returns

the currency rate

# File lib/momm/storage.rb, line 44
def get_rate(currency, date = Date.today)
  raise NotImplementedError
end
set_rate(currency, rate, date = Date.today) click to toggle source

Insert the currency rate to client

Parameters

currency

Currency passed in, should be a symbol of iso code, such as :CNY, :USD, or :GBP

rate

Fixnum represent for the currency rate from euro to certain currency

date

Ruby date type, the date of currency rate, today by default

Returns

nil

# File lib/momm/storage.rb, line 29
def set_rate(currency, rate, date = Date.today)
  raise NotImplementedError
end
update(data) click to toggle source

update the data to storage

parameters

data

An array looks like [{date: Date.now, currency: :CNY, rate: 1.23} …]

Returns

“OK”

# File lib/momm/storage.rb, line 57
def update(data)
  data.each do |d|
    set_rate d[:currency], d[:rate], d[:date]
  end
  "OK"
end