Class: DeviceWizard::IOSResolver
- Inherits:
-
Object
- Object
- DeviceWizard::IOSResolver
- Defined in:
- lib/device_wizard.rb
Constant Summary collapse
- IPHONE =
'iphone'- IPAD =
'ipad'- IPOD =
'ipod'- REGEX =
Regexp.new('os ((\d+_?){2,3})\s')
Instance Method Summary collapse
Instance Method Details
#get_type(user_agent) ⇒ Object
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/device_wizard.rb', line 331 def get_type(user_agent) user_agent.downcase! if user_agent.include? IPOD return 'IPod' end if user_agent.include? IPAD return 'IPad' end if user_agent.include? IPHONE return 'IPhone' end return UNKNOWN end |
#get_version(user_agent) ⇒ Object
320 321 322 323 324 325 326 327 328 329 |
# File 'lib/device_wizard.rb', line 320 def get_version(user_agent) user_agent.downcase! result = UNKNOWN if REGEX =~ user_agent result = $1 end return result.gsub('_','.') end |
#identify(user_agent) ⇒ Object
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/device_wizard.rb', line 349 def identify(user_agent) user_agent.downcase! if !user_agent.include? IPHONE if !user_agent.include? IPAD if !user_agent.include? IPOD return nil end end end result = OperatingSystemDetails.new result.name = 'IOS' result.type = get_type(user_agent) result.version = get_version(user_agent) return result end |