Class: Cellularity::Imei
- Inherits:
-
Object
- Object
- Cellularity::Imei
- Defined in:
- lib/cellularity/imei.rb
Instance Attribute Summary collapse
-
#imei ⇒ Object
Returns the value of attribute imei.
Instance Method Summary collapse
-
#initialize(imei = '') ⇒ Imei
constructor
A new instance of Imei.
- #valid? ⇒ Boolean
Constructor Details
#initialize(imei = '') ⇒ Imei
Returns a new instance of Imei.
6 7 8 |
# File 'lib/cellularity/imei.rb', line 6 def initialize(imei = '') self.imei = imei.to_s.gsub(/[^0-9]/, '') # Sometimes formatted as AA-BBBBBB-CCCCCC-D end |
Instance Attribute Details
#imei ⇒ Object
Returns the value of attribute imei.
4 5 6 |
# File 'lib/cellularity/imei.rb', line 4 def imei @imei end |
Instance Method Details
#valid? ⇒ Boolean
10 11 12 13 14 |
# File 'lib/cellularity/imei.rb', line 10 def valid? [15, 16].include?(self.imei.length) && !!Integer(self.imei) rescue ArgumentError, TypeError false end |