class UserAgent::Browsers::Opera

Public Class Methods

extend?(agent) click to toggle source
# 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

Public Instance Methods

browser() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 10
def browser
  'Opera'
end
localization() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 62
def localization
  return unless application.comment

  if macintosh?
    application.comment[3]
  else
    application.comment[2]
  end
end
mobile?() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 48
def mobile?
  mini?
end
os() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 52
def os
  return unless application.comment

  if application.comment[0] =~ /Windows/
    OperatingSystems.normalize_os(application.comment[0])
  else
    application.comment[1]
  end
end
platform() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 26
def platform
  return unless application.comment

  if application.comment[0] =~ /Windows/
    "Windows"
  else
    application.comment[0]
  end
end
security() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 36
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
version() click to toggle source
Calls superclass method UserAgent::Browsers::Base#version
# File lib/user_agent/browsers/opera.rb, line 14
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

Private Instance Methods

macintosh?() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 77
def macintosh?
  platform == 'Macintosh'
end
mini?() click to toggle source
# File lib/user_agent/browsers/opera.rb, line 73
def mini?
  /Opera Mini/ === application
end