Module: AppleModels

Defined in:
lib/apple_models.rb,
lib/apple_models/device.rb,
lib/apple_models/version.rb

Defined Under Namespace

Classes: Device

Constant Summary collapse

VERSION =
"2.1.2"
@@catalog =
[
  # identifier    model       version         extended
  [ 'AppleTV1,1', 'Apple TV', '1',            '' ],
  [ 'AppleTV2,1', 'Apple TV', '2',            '' ],
  [ 'AppleTV3,1', 'Apple TV', '3',            '' ],
  [ 'AppleTV3,2', 'Apple TV', '3',            '' ],
  [ 'iPad1,1',    'iPad',     '1',            '' ],
  [ 'iPad2,1',    'iPad',     '2',            '(WiFi)' ],
  [ 'iPad2,2',    'iPad',     '2',            '(GSM)' ],
  [ 'iPad2,3',    'iPad',     '2',            '(CDMA)' ],
  [ 'iPad2,4',    'iPad',     '2',            '' ],
  [ 'iPad2,5',    'iPad',     'Mini',         '(WiFi)' ],
  [ 'iPad2,6',    'iPad',     'Mini',         '(GSM)' ],
  [ 'iPad2,7',    'iPad',     'Mini',         '(Global)' ],
  [ 'iPad3,1',    'iPad',     '3',            '(WiFi)' ],
  [ 'iPad3,2',    'iPad',     '3',            '(CDMA)' ],
  [ 'iPad3,3',    'iPad',     '3',            '(GSM)' ],
  [ 'iPad3,4',    'iPad',     '4',            '(WiFi)' ],
  [ 'iPad3,5',    'iPad',     '4',            '(GSM)' ],
  [ 'iPad3,6',    'iPad',     '4',            '(Global)' ],
  [ 'iPad4,1',    'iPad',     'Air',          '(WiFi)' ],
  [ 'iPad4,2',    'iPad',     'Air',          '(Cellular)' ],
  [ 'iPad4,4',    'iPad',     'Mini Retina',  '(WiFi)' ],
  [ 'iPad4,5',    'iPad',     'Mini Retina',  '(Cellular)' ],
  [ 'iPad4,6',    'iPad',     'Mini Retina',  '' ],
  [ 'iPhone1,1',  'iPhone',   '2G',           '' ],
  [ 'iPhone1,2',  'iPhone',   '3G',           '' ],
  [ 'iPhone2,1',  'iPhone',   '3GS',          '' ],
  [ 'iPhone3,1',  'iPhone',   '4',            '(GSM)' ],
  [ 'iPhone3,2',  'iPhone',   '4',            '(GSM)' ],
  [ 'iPhone3,3',  'iPhone',   '4',            '(CDMA)' ],
  [ 'iPhone4,1',  'iPhone',   '4S',           '' ],
  [ 'iPhone5,1',  'iPhone',   '5',            '(GSM)' ],
  [ 'iPhone5,2',  'iPhone',   '5',            '(Global)' ],
  [ 'iPhone5,3',  'iPhone',   '5C',           '(GSM)' ],
  [ 'iPhone5,4',  'iPhone',   '5C',           '(Global)' ],
  [ 'iPhone6,1',  'iPhone',   '5S',           '(GSM)' ],
  [ 'iPhone6,2',  'iPhone',   '5S',           '(Global)' ],
  [ 'iPhone7,1',  'iPhone',   '6 Plus',       '' ],
  [ 'iPhone7,2',  'iPhone',   '6',            '' ],
  [ 'iProd0,1',   'iPad',     'Prototype',    '' ],
  [ 'iPod1,1',    'iPod',     'Touch 1G',     '' ],
  [ 'iPod2,1',    'iPod',     'Touch 2G',     '' ],
  [ 'iPod2,2',    'iPod',     'Touch 3',      '' ],
  [ 'iPod3,1',    'iPod',     'Touch 3',      '' ],
  [ 'iPod4,1',    'iPod',     'Touch 4',      '' ],
  [ 'iPod5,1',    'iPod',     'Touch 5',      '' ],
]

Class Method Summary collapse

Class Method Details

.find(product_id) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/apple_models.rb', line 54

def self.find(product_id)
  if (match = @@catalog.select { |i| i[0] == product_id }.first)
    Device.new  identifier: match[0],
                model:      match[1],
                version:    match[2],
                extended:   match[3]
  end
end