1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
class UserAgent
module Browsers
class Opera < Base
def self.extend?(agent)
(agent.first && agent.first.product == 'Opera') ||
(agent.application && agent.application.product == 'Opera') ||
(agent.last && agent.last.product == 'OPR')
end
def browser
'Opera'
end
def version
if mini?
Version.new(application.comment.detect{|c| c =~ /Opera Mini/}[/Opera Mini\/([\d\.]+)/, 1]) rescue Version.new
elsif product = detect_product('Version')
Version.new(product.version)
elsif product = detect_product('OPR')
Version.new(product.version)
else
super
end
end
def platform
return unless application.comment
if application.comment[0] =~ /Windows/
"Windows"
else
application.comment[0]
end
end
def security
if application.comment.nil?
:strong
elsif macintosh?
Security[application.comment[2]]
elsif mini?
Security[application.comment[-2]]
else
Security[application.comment[1]]
end
end
def mobile?
mini?
end
def os
return unless application.comment
if application.comment[0] =~ /Windows/
OperatingSystems.normalize_os(application.comment[0])
else
application.comment[1]
end
end
def localization
return unless application.comment
if macintosh?
application.comment[3]
else
application.comment[2]
end
end
private
def mini?
/Opera Mini/ === application
end
def macintosh?
platform == 'Macintosh'
end
end
end
end
|