Sha256: 67b1dc3c6338046b94556e4a4fb3941cdb37106fb99f34ab070a8d2ca7674018

Contents?: true

Size: 410 Bytes

Versions: 8

Compression:

Stored size: 410 Bytes

Contents

module Imb

  # @!group Internal

  # Numeric conversions

  module NumericConversions

    # Convert a numeric to an array of at least +min_bytes+ bytes.
    # @param [Numeric] n
    # @param [Integer] min_bytes
    # @return [[Integer]] Array of bytes

    def numeric_to_bytes(n, min_bytes=0)
      n.to_s(16).rjust(2 * min_bytes, '0').scan(/../).map do |s|
        s.to_i(16)
      end
    end

  end

end

Version data entries

8 entries across 7 versions & 2 rubygems

Version Path
usps_intelligent_barcode-0.3.1 lib/usps_intelligent_barcode/numeric_conversions.rb
USPS-intelligent-barcode-0.2.7 lib/USPS-intelligent-barcode/numeric_conversions.rb
USPS-intelligent-barcode-0.2.6 lib/USPS-intelligent-barcode/numeric_conversions.rb
usps_intelligent_barcode-0.3.0 lib/USPS-intelligent-barcode/numeric_conversions.rb
usps_intelligent_barcode-0.3.0 lib/usps_intelligent_barcode/numeric_conversions.rb
USPS-intelligent-barcode-0.2.5 lib/USPS-intelligent-barcode/numeric_conversions.rb
USPS-intelligent-barcode-0.2.4 lib/USPS-intelligent-barcode/numeric_conversions.rb
USPS-intelligent-barcode-0.2.3 lib/USPS-intelligent-barcode/NumericConversions.rb