Class: UserAgent::Browsers::Gecko

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

Constant Summary collapse

GeckoBrowsers =
%w(
  PaleMoon
  Firefox
  Camino
  Iceweasel
  Seamonkey
).freeze

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/gecko.rb', line 4

def self.extend?(agent)
  agent.application && agent.application.product == "Mozilla"
end

Instance Method Details

#browserObject



16
17
18
# File 'lib/user_agent/browsers/gecko.rb', line 16

def browser
  GeckoBrowsers.detect { |browser| respond_to?(browser) } || super
end

#localizationObject



59
60
61
62
63
# File 'lib/user_agent/browsers/gecko.rb', line 59

def localization
  if comment = application.comment
    comment[3]
  end
end

#osObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/user_agent/browsers/gecko.rb', line 41

def os
  if comment = application.comment
    i = if comment[1] == 'U'
          2
        elsif /^Windows / =~ comment[0] || /^Android/ =~ comment[0]
          0
        elsif comment[0] == 'Mobile'
          nil
        else
          1
        end

    return nil if i.nil?
    
    OperatingSystems.normalize_os(comment[i])
  end
end

#platformObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/user_agent/browsers/gecko.rb', line 25

def platform
  if comment = application.comment
    if comment[0] == 'compatible' || comment[0] == 'Mobile'
      nil
    elsif /^Windows / =~ comment[0]
      'Windows'
    else
      comment[0]
    end
  end
end

#securityObject



37
38
39
# File 'lib/user_agent/browsers/gecko.rb', line 37

def security
  Security[application.comment[1]] || :strong
end

#versionObject



20
21
22
23
# File 'lib/user_agent/browsers/gecko.rb', line 20

def version
  v = send(browser).version
  v.nil? ? super : v
end