Sha256: 9f811b65c94fb966614c95af0a66c1e9bb285dd313dee49341a530bc50a518c0
Contents?: true
Size: 509 Bytes
Versions: 1
Compression:
Stored size: 509 Bytes
Contents
require "forwardable" module RussianPost module Barcode class Base extend Forwardable def_delegator :barcode, :=~ attr_reader :barcode, :digits def self.format /.*/ end def initialize(barcode) @barcode = barcode.strip.upcase @digits = barcode.scan(/\d/).map { |d| d.to_i } end def valid? barcode =~ self.class.format && digits.last == checkdigit end def to_s barcode end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
russianpost-0.6.0 | lib/russianpost/barcode/base.rb |