Class: UserAgent::Browsers::Opera

Inherits:
Base
  • Object
show all
Defined in:
lib/user_agent/browsers/opera.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#<=>, #application, #bot?, #eql?, #method_missing, #respond_to?, #to_s, #to_str

Methods included from Comparable

#<, #<=, #==, #>, #>=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class UserAgent::Browsers::Base

Class Method Details

.extend?(agent) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
# File 'lib/user_agent/browsers/opera.rb', line 4

def self.extend?(agent)
  (agent.first && agent.first.product == 'Opera') ||
    (agent.application && agent.application.product == 'Opera') ||
      (agent.last && agent.last.product == 'OPR')
end

Instance Method Details

#browserObject



10
11
12
# File 'lib/user_agent/browsers/opera.rb', line 10

def browser
  'Opera'
end

#localizationObject



60
61
62
63
64
65
66
67
68
# File 'lib/user_agent/browsers/opera.rb', line 60

def localization
  if application.comment.nil?
    nil
  elsif platform == "Macintosh"
    application.comment[3]
  else
    application.comment[2]
  end
end

#mobile?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/user_agent/browsers/opera.rb', line 46

def mobile?
  mini?
end

#osObject



50
51
52
53
54
55
56
57
58
# File 'lib/user_agent/browsers/opera.rb', line 50

def os
  if application.comment.nil?
    nil
  elsif application.comment[0] =~ /Windows/
    OperatingSystems.normalize_os(application.comment[0])
  else
    application.comment[1]
  end
end

#platformObject



24
25
26
27
28
29
30
31
32
# File 'lib/user_agent/browsers/opera.rb', line 24

def platform
  if application.comment.nil?
    nil
  elsif application.comment[0] =~ /Windows/
    "Windows"
  else
    application.comment[0]
  end
end

#securityObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/user_agent/browsers/opera.rb', line 34

def security
  if application.comment.nil?
    :strong
  elsif platform == "Macintosh"
    Security[application.comment[2]]
  elsif mini?
    Security[application.comment[-2]]
  else
    Security[application.comment[1]]
  end
end

#versionObject



14
15
16
17
18
19
20
21
22
# File 'lib/user_agent/browsers/opera.rb', line 14

def version
  if mini?
    application.comment.detect{|c| c =~ /Opera Mini/}[/Opera Mini\/([\d\.]+)/, 1] rescue Version.new
  elsif product = detect_product('Version')
    product.version
  else
    super
  end
end