Sha256: 4e7048d945be54b150b6632bb6d63319054688fc1d8c52f059506d5b48852588

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

class UserAgent
  module Browsers
    class WechatBrowser < Base
      def self.extend?(agent)
        agent.detect { |useragent| useragent.product =~ /MicroMessenger/i }
      end

      def browser
        'Wechat Browser'
      end

      def version
        micro_messenger = detect_product("MicroMessenger")
        Version.new(micro_messenger.version)
      end

      def platform
        return unless application

        if application.comment[0] =~ /iPhone/
          'iPhone'
        elsif application.comment.any? { |c| c =~ /Android/ }
          'Android'
        else
          application.comment[0]
        end
      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
useragent-0.16.9 lib/user_agent/browsers/wechat_browser.rb
useragent-0.16.8 lib/user_agent/browsers/wechat_browser.rb