Class: Bakong::Khqr::MerchantCode::MerchantCategoryCode
- Inherits:
-
TagLengthString
- Object
- TagLengthString
- Bakong::Khqr::MerchantCode::MerchantCategoryCode
- Defined in:
- lib/bakong/khqr/merchant_code/merchant_category_code.rb
Instance Attribute Summary
Attributes inherited from TagLengthString
Instance Method Summary collapse
-
#initialize(tag, value) ⇒ MerchantCategoryCode
constructor
A new instance of MerchantCategoryCode.
Methods inherited from TagLengthString
Constructor Details
#initialize(tag, value) ⇒ MerchantCategoryCode
Returns a new instance of MerchantCategoryCode.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bakong/khqr/merchant_code/merchant_category_code.rb', line 12 def initialize(tag, value) raise Error.from(ERROR_CODES[:MERCHANT_CATEGORY_TAG_REQUIRED]) if value.nil? || value == "" if value.length > EMV[:INVALID_LENGTH][:MERCHANT_CATEGORY_CODE] raise Error.from(ERROR_CODES[:MERCHANT_CODE_LENGTH_INVALID]) end raise Error.from(ERROR_CODES[:INVALID_MERCHANT_CATEGORY_CODE]) unless value.match?(/\A\d+\z/) mcc = value.to_i raise Error.from(ERROR_CODES[:INVALID_MERCHANT_CATEGORY_CODE]) if mcc.negative? || mcc > 9999 super end |