Class: Bakong::Khqr::MerchantCode::TransactionCurrency
- Inherits:
-
TagLengthString
- Object
- TagLengthString
- Bakong::Khqr::MerchantCode::TransactionCurrency
- Defined in:
- lib/bakong/khqr/merchant_code/transaction_currency.rb
Instance Attribute Summary
Attributes inherited from TagLengthString
Instance Method Summary collapse
-
#initialize(tag, value) ⇒ TransactionCurrency
constructor
A new instance of TransactionCurrency.
Methods inherited from TagLengthString
Constructor Details
#initialize(tag, value) ⇒ TransactionCurrency
Returns a new instance of TransactionCurrency.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bakong/khqr/merchant_code/transaction_currency.rb', line 12 def initialize(tag, value) raise Error.from(ERROR_CODES[:CURRENCY_TYPE_REQUIRED]) if value.nil? || value == "" string_value = value.to_s raise Error.from(ERROR_CODES[:TRANSACTION_CURRENCY_LENGTH_INVALID]) if string_value.length > 3 unless [CURRENCY[:khr], CURRENCY[:usd]].include?(string_value.to_i) raise Error.from(ERROR_CODES[:UNSUPPORTED_CURRENCY]) end super(tag, string_value) end |