Sha256: 88d6277ab24ed1fe7c1398d832cef5235ef1f46596d217ff50389e2ee77223bf
Contents?: true
Size: 536 Bytes
Versions: 5
Compression:
Stored size: 536 Bytes
Contents
require "forwardable" require "russianpost/barcode_validator" module RussianPost class Barcode extend Forwardable def_delegator :barcode, :=~ attr_reader :barcode def initialize(barcode) @barcode = barcode.strip.upcase raise InvalidBarcode unless valid? end def to_s barcode end def digits barcode[/\d+/].split("").map { |d| d.to_i } end private def valid? BarcodeValidator.validate(self) end end class InvalidBarcode < ArgumentError; end end
Version data entries
5 entries across 5 versions & 1 rubygems