Class: MobileESPConverted::UserAgentInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/mobileesp_converted/user_agent_info.rb

Constant Summary collapse

ENGINE_WEB_KIT =
"webkit"
DEVICE_IPHONE =
"iphone"
DEVICE_IPOD =
"ipod"
DEVICE_IPAD =
"ipad"
DEVICE_MAC_PPC =
"macintosh"
DEVICE_ANDROID =
"android"
DEVICE_GOOGLE_T_V =
"googletv"
DEVICE_WIN_PHONE7 =
"windows phone os 7"
DEVICE_WIN_PHONE8 =
"windows phone 8"
DEVICE_WIN_PHONE10 =
"windows phone 10"
DEVICE_WIN_MOB =
"windows ce"
DEVICE_WINDOWS =
"windows"
DEVICE_IE_MOB =
"iemobile"
DEVICE_PPC =
"ppc"
ENGINE_PIE =
"wm5 pie"
DEVICE_B_B =
"blackberry"
DEVICE_B_B10 =
"bb10"
VND_R_I_M =
"vnd.rim"
DEVICE_B_B_STORM =
"blackberry95"
DEVICE_B_B_BOLD =
"blackberry97"
DEVICE_B_B_BOLD_TOUCH =
"blackberry 99"
DEVICE_B_B_TOUR =
"blackberry96"
DEVICE_B_B_CURVE =
"blackberry89"
DEVICE_B_B_CURVE_TOUCH =
"blackberry 938"
DEVICE_B_B_TORCH =
"blackberry 98"
DEVICE_B_B_PLAYBOOK =
"playbook"
DEVICE_SYMBIAN =
"symbian"
DEVICE_S60 =
"series60"
DEVICE_S70 =
"series70"
DEVICE_S80 =
"series80"
DEVICE_S90 =
"series90"
DEVICE_PALM =
"palm"
DEVICE_WEB_O_S =
"webos"
DEVICE_WEB_O_STV =
"web0s"
DEVICE_WEB_O_SHP =
"hpwos"
DEVICE_NUVIFONE =
"nuvifone"
DEVICE_BADA =
"bada"
DEVICE_TIZEN =
"tizen"
DEVICE_MEEGO =
"meego"
DEVICE_SAILFISH =
"sailfish"
DEVICE_UBUNTU =
"ubuntu"
DEVICE_KINDLE =
"kindle"
ENGINE_SILK =
"silk-accelerated"
ENGINE_BLAZER =
"blazer"
ENGINE_XIINO =
"xiino"
VNDWAP =
"vnd.wap"
WML =
"wml"
DEVICE_TABLET =
"tablet"
DEVICE_BREW =
"brew"
DEVICE_DANGER =
"danger"
DEVICE_HIPTOP =
"hiptop"
DEVICE_PLAYSTATION =
"playstation"
DEVICE_PLAYSTATION_VITA =
"vita"
DEVICE_NINTENDO_DS =
"nitro"
DEVICE_NINTENDO =
"nintendo"
DEVICE_WII =
"wii"
DEVICE_XBOX =
"xbox"
DEVICE_ARCHOS =
"archos"
ENGINE_FIREFOX =
"firefox"
ENGINE_OPERA =
"opera"
ENGINE_NETFRONT =
"netfront"
ENGINE_UP_BROWSER =
"up.browser"
ENGINE_OPEN_WEB =
"openweb"
DEVICE_MIDP =
"midp"
"up.link"
ENGINE_TELECA_Q =
"teleca q"
DEVICE_PDA =
"pda"
MINI =
"mini"
MOBILE =
"mobile"
MOBI =
"mobi"
SMART_T_V1 =
"smart-tv"
SMART_T_V2 =
"smarttv"
MAEMO =
"maemo"
LINUX =
"linux"
QTEMBEDDED =
"qt embedded"
MYLOCOM2 =
"com2"
MANU_SONY_ERICSSON =
"sonyericsson"
MANUERICSSON =
"ericsson"
MANU_SAMSUNG1 =
"sec-sgh"
MANU_SONY =
"sony"
MANU_HTC =
"htc"
SVC_DOCOMO =
"docomo"
SVC_KDDI =
"kddi"
SVC_VODAFONE =
"vodafone"
DIS_UPDATE =
"update"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_agent, http_accept) ⇒ UserAgentInfo

*

* Initialize the user_agent and http_accept variables
*
* @param user_agent the User-Agent header
* @param http_accept the Accept header


225
226
227
228
229
230
231
232
233
234
235
# File 'lib/mobileesp_converted/user_agent_info.rb', line 225

def initialize(user_agent, http_accept)
  if (user_agent != nil)
    @user_agent = user_agent.downcase
  end
  if (http_accept != nil)
    @http_accept = http_accept.downcase
  end


  init_device_scan()
end

Instance Attribute Details

#http_acceptObject (readonly)

Returns the value of attribute http_accept.



91
92
93
# File 'lib/mobileesp_converted/user_agent_info.rb', line 91

def http_accept
  @http_accept
end

#init_completedObject (readonly)

Returns the value of attribute init_completed.



94
95
96
# File 'lib/mobileesp_converted/user_agent_info.rb', line 94

def init_completed
  @init_completed
end

#is_androidObject (readonly)

Returns the value of attribute is_android.



98
99
100
# File 'lib/mobileesp_converted/user_agent_info.rb', line 98

def is_android
  @is_android
end

#is_android_phoneObject (readonly)

Returns the value of attribute is_android_phone.



99
100
101
# File 'lib/mobileesp_converted/user_agent_info.rb', line 99

def is_android_phone
  @is_android_phone
end

#is_iphoneObject (readonly)

Returns the value of attribute is_iphone.



97
98
99
# File 'lib/mobileesp_converted/user_agent_info.rb', line 97

def is_iphone
  @is_iphone
end

#is_mobile_phoneObject (readonly)

Returns the value of attribute is_mobile_phone.



96
97
98
# File 'lib/mobileesp_converted/user_agent_info.rb', line 96

def is_mobile_phone
  @is_mobile_phone
end

#is_tier_generic_mobileObject (readonly)

Returns the value of attribute is_tier_generic_mobile.



103
104
105
# File 'lib/mobileesp_converted/user_agent_info.rb', line 103

def is_tier_generic_mobile
  @is_tier_generic_mobile
end

#is_tier_iphoneObject (readonly)

Returns the value of attribute is_tier_iphone.



101
102
103
# File 'lib/mobileesp_converted/user_agent_info.rb', line 101

def is_tier_iphone
  @is_tier_iphone
end

#is_tier_rich_cssObject (readonly)

Returns the value of attribute is_tier_rich_css.



102
103
104
# File 'lib/mobileesp_converted/user_agent_info.rb', line 102

def is_tier_rich_css
  @is_tier_rich_css
end

#is_tier_tabletObject (readonly)

Returns the value of attribute is_tier_tablet.



100
101
102
# File 'lib/mobileesp_converted/user_agent_info.rb', line 100

def is_tier_tablet
  @is_tier_tablet
end

#is_webkitObject (readonly)

Returns the value of attribute is_webkit.



95
96
97
# File 'lib/mobileesp_converted/user_agent_info.rb', line 95

def is_webkit
  @is_webkit
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



90
91
92
# File 'lib/mobileesp_converted/user_agent_info.rb', line 90

def user_agent
  @user_agent
end

Instance Method Details

#detect_amazon_silkObject

*

* Detects if the current Amazon device is using the Silk Browser.
* Note: Typically used by the the Kindle Fire.
* @return detection of an Amazon Kindle Fire in Silk mode.


846
847
848
849
850
851
# File 'lib/mobileesp_converted/user_agent_info.rb', line 846

def detect_amazon_silk()
  if (user_agent.include?(ENGINE_SILK))
    return true
  end
  return false
end

#detect_androidObject

*

* Detects *any* Android OS-based device: phone, tablet, and multi-media player.
* Also detects Google TV.
* @return detection of an Android device


408
409
410
411
412
413
414
415
# File 'lib/mobileesp_converted/user_agent_info.rb', line 408

def detect_android()
  if ((user_agent.include?(DEVICE_ANDROID)) ||
      detect_google_t_v())
    return true
  end

  return false
end

#detect_android_phoneObject

*

* Detects if the current device is a (small-ish) Android OS-based device
* used for calling and/or multi-media (like a Samsung Galaxy Player).
* Google says these devices will have 'Android' AND 'mobile' in user agent.
* Ignores tablets (Honeycomb and later).
* @return  detection of an Android phone


426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/mobileesp_converted/user_agent_info.rb', line 426

def detect_android_phone()

  if (!detect_android())
    return false
  end


  if (user_agent.include?(MOBILE))
    return true
  end


  if (detect_opera_mobile())
    return true
  end

  return false
end

#detect_android_tabletObject

*

* Detects if the current device is a (self-reported) Android tablet.
* Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
* @return detection of an Android tablet


452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/mobileesp_converted/user_agent_info.rb', line 452

def detect_android_tablet()

  if (!detect_android())
    return false
  end


  if (detect_opera_mobile())
    return false
  end


  if ((user_agent.include?(MOBILE)))
    return false
  else
    return true
  end
end

#detect_android_web_kitObject

*

* Detects if the current device is an Android OS-based device and
* the browser is based on WebKit.
* @return detection of an Android WebKit browser


478
479
480
481
482
483
# File 'lib/mobileesp_converted/user_agent_info.rb', line 478

def detect_android_web_kit()
  if (detect_android() && detect_webkit())
    return true
  end
  return false
end

#detect_archosObject

*

* Detects if the current device is an Archos media player/Internet tablet.
* @return detection of an Archos media player


1104
1105
1106
1107
1108
1109
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1104

def detect_archos()
  if (user_agent.include?(DEVICE_ARCHOS))
    return true
  end
  return false
end

#detect_badaObject

*

* Detects a device running the Bada OS from Samsung.
* @return detection of a Bada device


873
874
875
876
877
878
# File 'lib/mobileesp_converted/user_agent_info.rb', line 873

def detect_bada()
  if (user_agent.include?(DEVICE_BADA))
    return true
  end
  return false
end

#detect_black_berryObject

*

* Detects if the current browser is any BlackBerry.
* Includes BB10 OS, but excludes the PlayBook.
* @return detection of Blackberry


628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/mobileesp_converted/user_agent_info.rb', line 628

def detect_black_berry()
  if (user_agent.include?(DEVICE_B_B) ||
      http_accept.include?(VND_R_I_M))
    return true
  end

  if (detect_black_berry10_phone())
    return true
  end

  return false
end

#detect_black_berry10_phoneObject

*

* Detects if the current browser is a BlackBerry 10 OS phone.
* Excludes tablets.
* @return detection of a Blackberry 10 device


648
649
650
651
652
653
654
# File 'lib/mobileesp_converted/user_agent_info.rb', line 648

def detect_black_berry10_phone()
  if (user_agent.include?(DEVICE_B_B10) &&
      user_agent.include?(MOBILE))
    return true
  end
  return false
end

#detect_black_berry_highObject

*

* Detects if the current browser is a BlackBerry device AND
*   has a more capable recent browser. Excludes the Playbook.
*   Examples, Storm, Bold, Tour, Curve2
*   Excludes the new BlackBerry OS 6 and 7 browser!!
* @return detection of a Blackberry device with a better browser


713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'lib/mobileesp_converted/user_agent_info.rb', line 713

def detect_black_berry_high()

  if (detect_black_berry_web_kit())
    return false
  end
  if (detect_black_berry())
    if (detect_black_berry_touch() || user_agent.include?(DEVICE_B_B_BOLD) || user_agent.include?(DEVICE_B_B_TOUR) || user_agent.include?(DEVICE_B_B_CURVE))
      return true
    else
      return false
    end
  else
    return false
  end
end

#detect_black_berry_lowObject

*

* Detects if the current browser is a BlackBerry device AND
*   has an older, less capable browser.
*   Examples: Pearl, 8800, Curve1
* @return detection of a Blackberry device with a poorer browser


737
738
739
740
741
742
743
744
745
746
747
748
# File 'lib/mobileesp_converted/user_agent_info.rb', line 737

def detect_black_berry_low()
  if (detect_black_berry())

    if (detect_black_berry_high() || detect_black_berry_web_kit())
      return false
    else
      return true
    end
  else
    return false
  end
end

#detect_black_berry_tabletObject

*

* Detects if the current browser is on a BlackBerry tablet device.
*    Example: PlayBook
* @return detection of a Blackberry Tablet


663
664
665
666
667
668
# File 'lib/mobileesp_converted/user_agent_info.rb', line 663

def detect_black_berry_tablet()
  if (user_agent.include?(DEVICE_B_B_PLAYBOOK))
    return true
  end
  return false
end

#detect_black_berry_touchObject

*

* Detects if the current browser is a BlackBerry Touch
* device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
* @return detection of a Blackberry touchscreen device


693
694
695
696
697
698
699
700
701
702
# File 'lib/mobileesp_converted/user_agent_info.rb', line 693

def detect_black_berry_touch()
  if (detect_black_berry() &&
      (user_agent.include?(DEVICE_B_B_STORM) ||
       user_agent.include?(DEVICE_B_B_TORCH) ||
       user_agent.include?(DEVICE_B_B_BOLD_TOUCH) ||
       user_agent.include?(DEVICE_B_B_CURVE_TOUCH) ))
    return true
  end
  return false
end

#detect_black_berry_web_kitObject

*

* Detects if the current browser is a BlackBerry device AND uses a
*    WebKit-based browser. These are signatures for the new BlackBerry OS 6.
*    Examples: Torch. Includes the Playbook.
* @return detection of a Blackberry device with WebKit browser


678
679
680
681
682
683
684
# File 'lib/mobileesp_converted/user_agent_info.rb', line 678

def detect_black_berry_web_kit()
  if (detect_black_berry() &&
      user_agent.include?(ENGINE_WEB_KIT))
    return true
  end
  return false
end

#detect_brew_deviceObject

*

* Detects whether the device is a Brew-powered device.
* @return detection of a Brew device


1185
1186
1187
1188
1189
1190
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1185

def detect_brew_device()
  if (user_agent.include?(DEVICE_BREW))
    return true
  end
  return false
end

#detect_danger_hiptopObject

*

* Detects the Danger Hiptop device.
* @return detection of a Danger Hiptop


1063
1064
1065
1066
1067
1068
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1063

def detect_danger_hiptop()
  if (user_agent.include?(DEVICE_DANGER) || user_agent.include?(DEVICE_HIPTOP))
    return true
  end
  return false
end

#detect_firefox_o_sObject

*

* Detects a mobile device (probably) running the Firefox OS.
* @return detection of a Firefox OS mobile device


941
942
943
944
945
946
947
# File 'lib/mobileesp_converted/user_agent_info.rb', line 941

def detect_firefox_o_s()
  if (detect_firefox_o_s_phone() || detect_firefox_o_s_tablet())
    return true
  end

  return false
end

#detect_firefox_o_s_phoneObject

*

* Detects a phone (probably) running the Firefox OS.
* @return detection of a Firefox OS phone


955
956
957
958
959
960
961
962
963
964
965
966
# File 'lib/mobileesp_converted/user_agent_info.rb', line 955

def detect_firefox_o_s_phone()

  if (detect_ios() || detect_android() || detect_sailfish())
    return false
  end

  if ((user_agent.include?(ENGINE_FIREFOX)) && (user_agent.include?(MOBILE)))
    return true
  end

  return false
end

#detect_firefox_o_s_tabletObject

*

* Detects a tablet (probably) running the Firefox OS.
* @return detection of a Firefox OS tablet


974
975
976
977
978
979
980
981
982
983
984
985
# File 'lib/mobileesp_converted/user_agent_info.rb', line 974

def detect_firefox_o_s_tablet()

  if (detect_ios() || detect_android() || detect_sailfish())
    return false
  end

  if ((user_agent.include?(ENGINE_FIREFOX)) && (user_agent.include?(DEVICE_TABLET)))
    return true
  end

  return false
end

#detect_game_consoleObject

*

* Detects if the current device is an Internet-capable game console.
* Includes many handheld consoles.
* @return detection of any Game Console


1118
1119
1120
1121
1122
1123
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1118

def detect_game_console()
  if (detect_sony_playstation() || detect_nintendo() || detect_xbox())
    return true
  end
  return false
end

#detect_gaming_handheldObject

*

* Detects if the current device is a handheld gaming device with
* a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
* @return detection of a handheld gaming device


1145
1146
1147
1148
1149
1150
1151
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1145

def detect_gaming_handheld()
  if ((user_agent.include?(DEVICE_PLAYSTATION)) &&
      (user_agent.include?(DEVICE_PLAYSTATION_VITA)))
    return true
  end
  return false
end

#detect_garmin_nuvifoneObject

*

* Detects if the current browser is a
*    Garmin Nuvifone.
* @return detection of a Garmin Nuvifone


860
861
862
863
864
865
# File 'lib/mobileesp_converted/user_agent_info.rb', line 860

def detect_garmin_nuvifone()
  if (user_agent.include?(DEVICE_NUVIFONE))
    return true
  end
  return false
end

#detect_google_t_vObject

*

* Detects if the current device is a GoogleTV.
* @return detection of GoogleTV


491
492
493
494
495
496
# File 'lib/mobileesp_converted/user_agent_info.rb', line 491

def detect_google_t_v()
  if (user_agent.include?(DEVICE_GOOGLE_T_V))
    return true
  end
  return false
end

#detect_iosObject

*

* Detects *any* iOS device: iPhone, iPod Touch, iPad.
* @return detection of an Apple iOS device


393
394
395
396
397
398
# File 'lib/mobileesp_converted/user_agent_info.rb', line 393

def detect_ios()
  if (detect_iphone_or_ipod() || detect_ipad())
    return true
  end
  return false
end

#detect_ipadObject

*

* Detects if the current device is an iPad tablet.
* @return detection of an iPad


366
367
368
369
370
371
# File 'lib/mobileesp_converted/user_agent_info.rb', line 366

def detect_ipad()
  if (user_agent.include?(DEVICE_IPAD) && detect_webkit())
    return true
  end
  return false
end

#detect_iphoneObject

*

* Detects if the current device is an iPhone.
* @return detection of an iPhone


337
338
339
340
341
342
343
344
345
# File 'lib/mobileesp_converted/user_agent_info.rb', line 337

def detect_iphone()

  if (user_agent.include?(DEVICE_IPHONE) &&
      !detect_ipad() &&
      !detect_ipod())
    return true
  end
  return false
end

#detect_iphone_or_ipodObject

*

* Detects if the current device is an iPhone or iPod Touch.
* @return detection of an iPhone or iPod Touch


379
380
381
382
383
384
385
# File 'lib/mobileesp_converted/user_agent_info.rb', line 379

def detect_iphone_or_ipod()

  if (detect_iphone() || user_agent.include?(DEVICE_IPOD))
    return true
  end
  return false
end

#detect_ipodObject

*

* Detects if the current device is an iPod Touch.
* @return detection of an iPod Touch


353
354
355
356
357
358
# File 'lib/mobileesp_converted/user_agent_info.rb', line 353

def detect_ipod()
  if (user_agent.include?(DEVICE_IPOD))
    return true
  end
  return false
end

#detect_kindleObject

*

* Detects if the current device is an Amazon Kindle (eInk devices only).
* Note: For the Kindle Fire, use the normal Android methods.
* @return detection of a Kindle


831
832
833
834
835
836
837
# File 'lib/mobileesp_converted/user_agent_info.rb', line 831

def detect_kindle()
  if (user_agent.include?(DEVICE_KINDLE) &&
      !detect_android())
    return true
  end
  return false
end

#detect_maemo_tabletObject

*

* Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
* @return detection of a Maemo OS tablet


1089
1090
1091
1092
1093
1094
1095
1096
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1089

def detect_maemo_tablet()
  if (user_agent.include?(MAEMO))
    return true
  elsif (user_agent.include?(LINUX) && user_agent.include?(DEVICE_TABLET) && !detect_web_o_s_tablet() && !detect_android())
    return true
  end
  return false
end

#detect_meegoObject

*

* Detects a device running the Meego OS.
* @return detection of a Meego device


914
915
916
917
918
919
# File 'lib/mobileesp_converted/user_agent_info.rb', line 914

def detect_meego()
  if (user_agent.include?(DEVICE_MEEGO))
    return true
  end
  return false
end

#detect_meego_phoneObject

*

* Detects a phone running the Meego OS.
* @return detection of a Meego phone


927
928
929
930
931
932
933
# File 'lib/mobileesp_converted/user_agent_info.rb', line 927

def detect_meego_phone()
  if (user_agent.include?(DEVICE_MEEGO) &&
      user_agent.include?(MOBI))
    return true
  end
  return false
end

#detect_midp_capableObject

*

* Detects if the current device supports MIDP, a mobile Java technology.
* @return detection of a MIDP mobile Java-capable device


1211
1212
1213
1214
1215
1216
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1211

def detect_midp_capable()
  if (user_agent.include?(DEVICE_MIDP) || http_accept.include?(DEVICE_MIDP))
    return true
  end
  return false
end

#detect_mobile_longObject

*

* The longer and more thorough way to detect for a mobile device.
*   Will probably detect most feature phones,
*   smartphone-class devices, Internet Tablets,
*   Internet-enabled game consoles, etc.
*   This ought to catch a lot of the more obscure and older devices, also --
*   but no promises on thoroughness!
* @return detection of any mobile device using the more thorough method


1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1290

def detect_mobile_long()
  if (detect_mobile_quick() || detect_game_console())
    return true
  end

  if (detect_danger_hiptop() || detect_maemo_tablet() || detect_sony_mylo() || detect_archos())
    return true
  end

  if ((user_agent.include?(DEVICE_PDA)) &&
      (!user_agent.include?(DIS_UPDATE)))
    return true
  end


  if ((user_agent.include?(UPLINK)) || (user_agent.include?(ENGINE_OPEN_WEB)) || (user_agent.include?(MANU_SAMSUNG1)) || (user_agent.include?(MANU_SONY_ERICSSON)) || (user_agent.include?(MANUERICSSON)) || (user_agent.include?(SVC_DOCOMO)) || (user_agent.include?(SVC_KDDI)) || (user_agent.include?(SVC_VODAFONE)))
    return true
  end

  return false
end

#detect_mobile_quickObject

*

*    Detects if the current device is a mobile device.
*  This method catches most of the popular modern devices.
*  Excludes Apple iPads and other modern tablets.
* @return detection of any mobile device using the quicker method


1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1244

def detect_mobile_quick()

  if (is_tier_tablet)
    return false
  end

  if (detect_smartphone())
    return true
  end


  if (user_agent.include?(MOBILE))
    return true
  end

  if (detect_opera_mobile())
    return true
  end


  if (detect_kindle() || detect_amazon_silk())
    return true
  end

  if (detect_wap_wml() || detect_midp_capable() || detect_brew_device())
    return true
  end

  if ((user_agent.include?(ENGINE_NETFRONT)) || (user_agent.include?(ENGINE_UP_BROWSER)))
    return true
  end

  return false
end

#detect_nintendoObject

*

* Detects if the current device is a Nintendo game device.
* @return detection of Nintendo


1159
1160
1161
1162
1163
1164
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1159

def detect_nintendo()
  if (user_agent.include?(DEVICE_NINTENDO) || user_agent.include?(DEVICE_WII) || user_agent.include?(DEVICE_NINTENDO_DS))
    return true
  end
  return false
end

#detect_opera_mobileObject

*

* Detects Opera Mobile or Opera Mini.
* @return detection of an Opera browser for a mobile device


817
818
819
820
821
822
# File 'lib/mobileesp_converted/user_agent_info.rb', line 817

def detect_opera_mobile()
  if (user_agent.include?(ENGINE_OPERA) && (user_agent.include?(MINI) || user_agent.include?(MOBI)))
    return true
  end
  return false
end

#detect_palm_o_sObject

*

* Detects if the current browser is on a PalmOS device.
* @return detection of a PalmOS device


756
757
758
759
760
761
762
763
764
765
766
767
# File 'lib/mobileesp_converted/user_agent_info.rb', line 756

def detect_palm_o_s()

  if (user_agent.include?(DEVICE_PALM) || user_agent.include?(ENGINE_BLAZER) || user_agent.include?(ENGINE_XIINO))

    if (detect_palm_web_o_s())
      return false
    else
      return true
    end
  end
  return false
end

#detect_palm_web_o_sObject

*

* Detects if the current browser is on a Palm device
*    running the new WebOS.
* @return detection of a Palm WebOS device


776
777
778
779
780
781
# File 'lib/mobileesp_converted/user_agent_info.rb', line 776

def detect_palm_web_o_s()
  if (user_agent.include?(DEVICE_WEB_O_S))
    return true
  end
  return false
end

#detect_s60_oss_browserObject

*

* Detects if the current browser is the Symbian S60 Open Source Browser.
* @return detection of Symbian S60 Browser


517
518
519
520
521
522
523
# File 'lib/mobileesp_converted/user_agent_info.rb', line 517

def detect_s60_oss_browser()

  if (detect_webkit() && (user_agent.include?(DEVICE_SYMBIAN) || user_agent.include?(DEVICE_S60)))
    return true
  end
  return false
end

#detect_sailfishObject

*

* Detects a device running the Sailfish OS.
* @return detection of a Sailfish device


993
994
995
996
997
998
# File 'lib/mobileesp_converted/user_agent_info.rb', line 993

def detect_sailfish()
  if (user_agent.include?(DEVICE_SAILFISH))
    return true
  end
  return false
end

#detect_sailfish_phoneObject

*

* Detects a phone running the Sailfish OS.
* @return detection of a Sailfish phone


1006
1007
1008
1009
1010
1011
1012
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1006

def detect_sailfish_phone()
  if (detect_sailfish() && (user_agent.include?(MOBILE)))
    return true
  end

  return false
end

#detect_smartphoneObject

*

* Check to see whether the device is any device
*   in the 'smartphone' category.
* @return detection of a general smartphone device


1231
1232
1233
1234
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1231

def detect_smartphone()

  return (detect_tier_iphone() || detect_s60_oss_browser() || detect_symbian_o_s() || detect_windows_mobile() || detect_black_berry() || detect_meego_phone() || detect_palm_o_s())
end

#detect_sony_myloObject

*

* Detects if the current browser is a Sony Mylo device.
* @return detection of a Sony Mylo device


1076
1077
1078
1079
1080
1081
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1076

def detect_sony_mylo()
  if (user_agent.include?(MANU_SONY) && (user_agent.include?(QTEMBEDDED) || user_agent.include?(MYLOCOM2)))
    return true
  end
  return false
end

#detect_sony_playstationObject

*

* Detects if the current device is a Sony Playstation.
* @return detection of Sony Playstation


1131
1132
1133
1134
1135
1136
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1131

def detect_sony_playstation()
  if (user_agent.include?(DEVICE_PLAYSTATION))
    return true
  end
  return false
end

#detect_symbian_o_sObject

*

*
* Detects if the current device is any Symbian OS-based device,
*   including older S60, Series 70, Series 80, Series 90, and UIQ,
*   or other browsers running on these devices.
* @return detection of SymbianOS


534
535
536
537
538
539
# File 'lib/mobileesp_converted/user_agent_info.rb', line 534

def detect_symbian_o_s()
  if (user_agent.include?(DEVICE_SYMBIAN) || user_agent.include?(DEVICE_S60) || user_agent.include?(DEVICE_S70) || user_agent.include?(DEVICE_S80) || user_agent.include?(DEVICE_S90))
    return true
  end
  return false
end

#detect_tier_iphoneObject

*

* The quick way to detect for a tier of devices.
*   This method detects for devices which can
*   display iPhone-optimized web content.
*   Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.
* @return detection of any device in the iPhone/Android/Windows Phone/BlackBerry/WebOS Tier


1341
1342
1343
1344
1345
1346
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1341

def detect_tier_iphone()
  if (detect_iphone_or_ipod() || detect_android_phone() || detect_windows_phone() || detect_black_berry10_phone() || (detect_black_berry_web_kit() && detect_black_berry_touch()) || detect_palm_web_o_s() || detect_bada() || detect_tizen() || detect_firefox_o_s_phone() || detect_sailfish_phone() || detect_ubuntu_phone() || detect_gaming_handheld())
    return true
  end
  return false
end

#detect_tier_other_phonesObject

*

* The quick way to detect for a tier of devices.
*   This method detects for all other types of phones,
*   but excludes the iPhone and RichCSS Tier devices.
* @return detection of a mobile device in the less capable tier


1386
1387
1388
1389
1390
1391
1392
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1386

def detect_tier_other_phones()

  if (detect_mobile_long() && !detect_tier_iphone() && !detect_tier_rich_css())
    return true
  end
  return false
end

#detect_tier_rich_cssObject

*

* The quick way to detect for a tier of devices.
*   This method detects for devices which are likely to be capable
*   of viewing CSS content optimized for the iPhone,
*   but may not necessarily support JavaScript.
*   Excludes all iPhone Tier devices.
* @return detection of any device in the 'Rich CSS' Tier


1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1358

def detect_tier_rich_css()
  result = false


  if (detect_mobile_quick())


    if (!detect_tier_iphone() && !detect_kindle())




      if (detect_webkit() || detect_s60_oss_browser() || detect_black_berry_high() || detect_windows_mobile() || user_agent.include?(ENGINE_TELECA_Q))
        result= true
      end
    end
  end
  return result
end

#detect_tier_tabletObject

*

* The quick way to detect for a tier of devices.
*   This method detects for the new generation of
*   HTML 5 capable, larger screen tablets.
*   Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
* @return detection of any device in the Tablet Tier


1325
1326
1327
1328
1329
1330
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1325

def detect_tier_tablet()
  if (detect_ipad() || detect_android_tablet() || detect_black_berry_tablet() || detect_firefox_o_s_tablet() || detect_ubuntu_tablet() || detect_web_o_s_tablet())
    return true
  end
  return false
end

#detect_tizenObject

*

* Detects a device running the Tizen smartphone OS.
* @return detection of a Tizen device


886
887
888
889
890
891
892
# File 'lib/mobileesp_converted/user_agent_info.rb', line 886

def detect_tizen()
  if (user_agent.include?(DEVICE_TIZEN) &&
      user_agent.include?(MOBILE))
    return true
  end
  return false
end

#detect_tizen_t_vObject

*

* Detects if the current browser is on a Tizen smart TV.
* @return detection of a Tizen smart TV


900
901
902
903
904
905
906
# File 'lib/mobileesp_converted/user_agent_info.rb', line 900

def detect_tizen_t_v()
  if (user_agent.include?(DEVICE_TIZEN) &&
      user_agent.include?(SMART_T_V1))
    return true
  end
  return false
end

#detect_ubuntuObject

*

* Detects a mobile device running the Ubuntu Mobile OS.
* @return detection of an Ubuntu Mobile OS mobile device


1020
1021
1022
1023
1024
1025
1026
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1020

def detect_ubuntu()
  if (detect_ubuntu_phone() || detect_ubuntu_tablet())
    return true
  end

  return false
end

#detect_ubuntu_phoneObject

*

* Detects a phone running the Ubuntu Mobile OS.
* @return detection of an Ubuntu Mobile OS phone


1034
1035
1036
1037
1038
1039
1040
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1034

def detect_ubuntu_phone()
  if ((user_agent.include?(DEVICE_UBUNTU)) && (user_agent.include?(MOBILE)))
    return true
  end

  return false
end

#detect_ubuntu_tabletObject

*

* Detects a tablet running the Ubuntu Mobile OS.
* @return detection of an Ubuntu Mobile OS tablet


1048
1049
1050
1051
1052
1053
1054
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1048

def detect_ubuntu_tablet()
  if ((user_agent.include?(DEVICE_UBUNTU)) && (user_agent.include?(DEVICE_TABLET)))
    return true
  end

  return false
end

#detect_wap_wmlObject

*

* Detects whether the device supports WAP or WML.
* @return detection of a WAP- or WML-capable device


1198
1199
1200
1201
1202
1203
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1198

def detect_wap_wml()
  if (http_accept.include?(VNDWAP) || http_accept.include?(WML))
    return true
  end
  return false
end

#detect_web_o_s_t_vObject

*

* Detects if the current browser is on a WebOS smart TV.
* @return detection of a WebOS smart TV


803
804
805
806
807
808
809
# File 'lib/mobileesp_converted/user_agent_info.rb', line 803

def detect_web_o_s_t_v()
  if (user_agent.include?(DEVICE_WEB_O_STV) &&
      user_agent.include?(SMART_T_V2))
    return true
  end
  return false
end

#detect_web_o_s_tabletObject

*

* Detects if the current browser is on an HP tablet running WebOS.
* @return detection of an HP WebOS tablet


789
790
791
792
793
794
795
# File 'lib/mobileesp_converted/user_agent_info.rb', line 789

def detect_web_o_s_tablet()
  if (user_agent.include?(DEVICE_WEB_O_SHP) &&
      user_agent.include?(DEVICE_TABLET))
    return true
  end
  return false
end

#detect_webkitObject

*

* Detects if the current browser is based on WebKit.
* @return detection of a WebKit browser


504
505
506
507
508
509
# File 'lib/mobileesp_converted/user_agent_info.rb', line 504

def detect_webkit()
  if (user_agent.include?(ENGINE_WEB_KIT))
    return true
  end
  return false
end

#detect_windows_mobileObject

*

* Detects if the current browser is a Windows Mobile device.
* Excludes Windows Phone 7.x and 8 devices.
* Focuses on Windows Mobile 6.xx and earlier.
* @return detection of Windows Mobile


601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/mobileesp_converted/user_agent_info.rb', line 601

def detect_windows_mobile()
  if (detect_windows_phone())
    return false
  end



  if (user_agent.include?(DEVICE_WIN_MOB) || user_agent.include?(DEVICE_WIN_MOB) || user_agent.include?(DEVICE_IE_MOB) || user_agent.include?(ENGINE_PIE) || (user_agent.include?(MANU_HTC) && user_agent.include?(DEVICE_WINDOWS)) || (detect_wap_wml() && user_agent.include?(DEVICE_WINDOWS)))
    return true
  end


  if (user_agent.include?(DEVICE_PPC) &&
      !(user_agent.include?(DEVICE_MAC_PPC)))
    return true
  end

  return false
end

#detect_windows_phoneObject

*

* Detects if the current browser is a Windows Phone 7.x, 8, or 10 device
* @return detection of Windows Phone 7.x OR 8


547
548
549
550
551
552
# File 'lib/mobileesp_converted/user_agent_info.rb', line 547

def detect_windows_phone()
  if (detect_windows_phone7() || detect_windows_phone8() || detect_windows_phone10())
    return true
  end
  return false
end

#detect_windows_phone10Object

*

* Detects a Windows Phone 10 device (in mobile browsing mode).
* @return detection of Windows Phone 10


586
587
588
589
590
591
# File 'lib/mobileesp_converted/user_agent_info.rb', line 586

def detect_windows_phone10()
  if (user_agent.include?(DEVICE_WIN_PHONE10))
    return true
  end
  return false
end

#detect_windows_phone7Object

*

* Detects a Windows Phone 7 device (in mobile browsing mode).
* @return detection of Windows Phone 7


560
561
562
563
564
565
# File 'lib/mobileesp_converted/user_agent_info.rb', line 560

def detect_windows_phone7()
  if (user_agent.include?(DEVICE_WIN_PHONE7))
    return true
  end
  return false
end

#detect_windows_phone8Object

*

* Detects a Windows Phone 8 device (in mobile browsing mode).
* @return detection of Windows Phone 8


573
574
575
576
577
578
# File 'lib/mobileesp_converted/user_agent_info.rb', line 573

def detect_windows_phone8()
  if (user_agent.include?(DEVICE_WIN_PHONE8))
    return true
  end
  return false
end

#detect_xboxObject

*

* Detects if the current device is a Microsoft Xbox.
* @return detection of Xbox


1172
1173
1174
1175
1176
1177
# File 'lib/mobileesp_converted/user_agent_info.rb', line 1172

def detect_xbox()
  if (user_agent.include?(DEVICE_XBOX))
    return true
  end
  return false
end

#get_http_acceptObject

*

* Return the lower case HTTP_ACCEPT
* @return http_accept


253
254
255
# File 'lib/mobileesp_converted/user_agent_info.rb', line 253

def get_http_accept()
  return http_accept
end

#get_is_iphoneObject

*

* Return whether the device is an Iphone or iPod Touch
* @return is_iphone


263
264
265
# File 'lib/mobileesp_converted/user_agent_info.rb', line 263

def get_is_iphone()
  return is_iphone
end

#get_is_tier_generic_mobileObject

*

* Return whether the device is a generic, less-capable mobile device.
* @return is_tier_generic_mobile


303
304
305
# File 'lib/mobileesp_converted/user_agent_info.rb', line 303

def get_is_tier_generic_mobile()
  return is_tier_generic_mobile
end

#get_is_tier_iphoneObject

*

* Return whether the device is in the Iphone Tier.
* @return is_tier_iphone


283
284
285
# File 'lib/mobileesp_converted/user_agent_info.rb', line 283

def get_is_tier_iphone()
  return is_tier_iphone
end

#get_is_tier_rich_cssObject

*

* Return whether the device is in the 'Rich CSS' tier of mobile devices.
* @return is_tier_rich_css


293
294
295
# File 'lib/mobileesp_converted/user_agent_info.rb', line 293

def get_is_tier_rich_css()
  return is_tier_rich_css
end

#get_is_tier_tabletObject

*

* Return whether the device is in the Tablet Tier.
* @return is_tier_tablet


273
274
275
# File 'lib/mobileesp_converted/user_agent_info.rb', line 273

def get_is_tier_tablet()
  return is_tier_tablet
end

#get_user_agentObject

*

* Return the lower case HTTP_USER_AGENT
* @return user_agent


243
244
245
# File 'lib/mobileesp_converted/user_agent_info.rb', line 243

def get_user_agent()
  return user_agent
end

#init_device_scanObject

*

* Initialize Key Stored Values.


312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/mobileesp_converted/user_agent_info.rb', line 312

def init_device_scan()

  @is_webkit = detect_webkit()
  @is_iphone = detect_iphone()
  @is_android = detect_android()
  @is_android_phone = detect_android_phone()


  @is_mobile_phone = detect_mobile_quick()
  @is_tier_tablet = detect_tier_tablet()
  @is_tier_iphone = detect_tier_iphone()


  @is_tier_rich_css = detect_tier_rich_css()
  @is_tier_generic_mobile = detect_tier_other_phones()

  @init_completed = true
end