Class: Bakong::Khqr::TagLengthString
- Inherits:
-
Object
- Object
- Bakong::Khqr::TagLengthString
- Defined in:
- lib/bakong/khqr/tag_length_string.rb
Overview
EMVCo TLV primitive: a 2-char tag, 2-digit zero-padded length, and value. Length is the character count of the value (matches the JS upstream’s ‘String.length`, which counts UTF-16 code units — equivalent to Ruby’s ‘String#length` for any character in the BMP, which covers Khmer).
Direct Known Subclasses
MerchantCode::AccountInformation, MerchantCode::AcquiringBank, MerchantCode::AdditionalData, MerchantCode::BakongAccountID, MerchantCode::BillNumber, MerchantCode::CRC, MerchantCode::CountryCode, MerchantCode::GlobalUniqueIdentifier, MerchantCode::LanguagePreference, MerchantCode::MerchantCategoryCode, MerchantCode::MerchantCity, MerchantCode::MerchantCityAlternateLanguage, MerchantCode::MerchantId, MerchantCode::MerchantInformationLanguageTemplate, MerchantCode::MerchantName, MerchantCode::MerchantNameAlternateLanguage, MerchantCode::MobileNumber, MerchantCode::PayloadFormatIndicator, MerchantCode::PointOfInitiationMethod, MerchantCode::PurposeOfTransaction, MerchantCode::StoreLabel, MerchantCode::TerminalLabel, MerchantCode::TimeStamp, MerchantCode::TransactionAmount, MerchantCode::TransactionCurrency, MerchantCode::UnionpayMerchantAccount
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(tag, value) ⇒ TagLengthString
constructor
A new instance of TagLengthString.
- #to_s ⇒ Object
Constructor Details
#initialize(tag, value) ⇒ TagLengthString
Returns a new instance of TagLengthString.
12 13 14 15 16 17 |
# File 'lib/bakong/khqr/tag_length_string.rb', line 12 def initialize(tag, value) @tag = tag @value = value len = value.to_s.length @length = len < 10 ? "0#{len}" : len.to_s end |
Instance Attribute Details
#length ⇒ Object (readonly)
Returns the value of attribute length.
10 11 12 |
# File 'lib/bakong/khqr/tag_length_string.rb', line 10 def length @length end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
10 11 12 |
# File 'lib/bakong/khqr/tag_length_string.rb', line 10 def tag @tag end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/bakong/khqr/tag_length_string.rb', line 10 def value @value end |
Instance Method Details
#to_s ⇒ Object
19 20 21 |
# File 'lib/bakong/khqr/tag_length_string.rb', line 19 def to_s "#{@tag}#{@length}#{@value}" end |