Sha256: 16940f766964b36b0c8fb524f95ba586dd34d13cdbdd16ee59ba834bf2634d73

Contents?: true

Size: 334 Bytes

Versions: 4

Compression:

Stored size: 334 Bytes

Contents

module Cellularity
  class Imei

    attr_accessor :imei

    def initialize(imei = '')
      self.imei = imei.to_s.gsub(/[^0-9]/, '') # Sometimes formatted as AA-BBBBBB-CCCCCC-D
    end

    def valid?
      [15, 16].include?(self.imei.length) && !!Integer(self.imei)
    rescue ArgumentError, TypeError
      false
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cellularity-1.0.0 lib/cellularity/imei.rb
cellularity-0.0.2.1 lib/cellularity/imei.rb
cellularity-0.0.2 lib/cellularity/imei.rb
cellularity-0.0.1 lib/cellularity/imei.rb