Module: Bakong::Khqr::Helpers::CutString
- Defined in:
- lib/bakong/khqr/helpers/cut_string.rb
Overview
Slice off a single TLV (tag, length, value) from the head of an EMVCo string. Returns the parsed parts plus whatever remains for the caller to keep consuming.
Class Method Summary collapse
Class Method Details
.call(string) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/bakong/khqr/helpers/cut_string.rb', line 12 def call(string) tag = string[0, 2] length = string[2, 2].to_i value = string[4, length] remainder = string[(4 + length)..] || "" { tag: tag, value: value || "", remainder: remainder } end |