Sha256: 33523512ad9d0b17dc6ea3046136697651f80dee3531a7da7eb41551651b7a7e

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

class UserAgent
  module Browsers
    module Opera
      def self.extend?(agent)
        agent.application && agent.application.product == "Opera"
      end

      def version
        if product = detect_product('Version')
          product.version
        else
          super
        end
      end

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

      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

      def mini?
        /Opera Mini/ === application
      end

      def mobile?
        mini?
      end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
useragent-0.7.0 lib/user_agent/browsers/opera.rb