class Menthol::Account
Attributes
amount[R]
currency[R]
name[R]
provider[R]
Public Class Methods
new(provider, name, amount, currency)
click to toggle source
# File lib/menthol/account.rb, line 5 def initialize(provider, name, amount, currency) @provider = provider @name = name @currency = Money::Currency.find(currency) @amount = Money.new(amount || 0, @currency.iso_code) end
open(provider, configuration)
click to toggle source
# File lib/menthol/account.rb, line 12 def self.open(provider, configuration) new( provider, configuration["name"], configuration["amount"], configuration["currency"] ) end
Public Instance Methods
parse_amount(raw_amount)
click to toggle source
# File lib/menthol/account.rb, line 29 def parse_amount(raw_amount) amount = raw_amount.gsub(/[^\d\.]/, "").to_f amount_subunit = amount * @currency.subunit_to_unit @amount = Money.new(amount_subunit, @currency.iso_code) end