Sha256: 3146354898e4448f40fd227d652494122de16fdb5d2616f855725790eaad6238

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

class UserAgent
  module Browsers
    class Vivaldi < Base
      def self.extend?(agent)
        agent.detect { |useragent| useragent.product == 'Vivaldi' }
      end

      def browser
        'Vivaldi'
      end

      def build
        webkit.version
      end

      def version
        last.version
      end

      def application
        self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
      end

      def platform
        return unless application

        if application.comment[0] =~ /Windows/
          'Windows'
        elsif application.comment.any? { |c| c =~ /CrOS/ }
          'ChromeOS'
        elsif application.comment.any? { |c| c =~ /Android/ }
          'Android'
        else
          application.comment[0]
        end
      end

      def webkit
        detect_product("AppleWebKit")
      end

      def os
        return unless application

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

      def localization
        return unless application

        application.comment[3]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
useragent-0.16.11 lib/user_agent/browsers/vivaldi.rb
useragent-0.16.10 lib/user_agent/browsers/vivaldi.rb
useragent-0.16.9 lib/user_agent/browsers/vivaldi.rb
useragent-0.16.8 lib/user_agent/browsers/vivaldi.rb