Class: UserAgent::Browsers::WechatBrowser

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#<=>, #application, #bot?, #eql?, #method_missing, #mobile?, #respond_to?, #to_h, #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
# File 'lib/user_agent/browsers/wechat_browser.rb', line 4

def self.extend?(agent)
  agent.detect { |useragent| useragent.product =~ /MicroMessenger/i }
end

Instance Method Details

#browserObject



8
9
10
# File 'lib/user_agent/browsers/wechat_browser.rb', line 8

def browser
  'Wechat Browser'
end

#osObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/user_agent/browsers/wechat_browser.rb', line 29

def os
  return unless application && application.comment

  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

#platformObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/user_agent/browsers/wechat_browser.rb', line 17

def platform
  return unless application && application.comment

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

#versionObject



12
13
14
15
# File 'lib/user_agent/browsers/wechat_browser.rb', line 12

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