Module: UserAgent::Browsers::All

Includes:
Comparable
Defined in:
lib/user_agent/browsers/all.rb

Instance Method Summary collapse

Methods included from Comparable

#<, #<=, #==, #>, #>=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



51
52
53
# File 'lib/user_agent/browsers/all.rb', line 51

def method_missing(method, *args, &block)
  detect_product(method) || super
end

Instance Method Details

#<=>(other) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/user_agent/browsers/all.rb', line 6

def <=>(other)
  if respond_to?(:browser) && other.respond_to?(:browser) &&
      browser == other.browser
    version <=> Version.new(other.version)
  else
    false
  end
end

#applicationObject



27
28
29
# File 'lib/user_agent/browsers/all.rb', line 27

def application
  first
end

#bot?Boolean

Returns:

  • (Boolean)


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/user_agent/browsers/all.rb', line 84

def bot?
  # If UA has no application type, its probably generated by a
  # shitty bot.
  if application.nil?
    true

  # Match common case when bots refer to themselves as bots in
  # the application comment. There are no standards for how bots
  # should call themselves so its not an exhaustive method.
  #
  # If you want to expand the scope, override the method and
  # provide your own regexp. Any patches to future extend this
  # list will be rejected.
  elsif comment = application.comment
    comment.any? { |c| c =~ /bot/i }
  else
    false
  end
end

#browserObject



31
32
33
# File 'lib/user_agent/browsers/all.rb', line 31

def browser
  application && application.product
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/user_agent/browsers/all.rb', line 15

def eql?(other)
  self == other
end

#mobile?Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/user_agent/browsers/all.rb', line 59

def mobile?
  if browser == 'webOS'
    true
  elsif platform == 'Symbian'
    true
  elsif detect_product('Mobile') || detect_comment('Mobile')
    true
  elsif os =~ /Android/
    true
  elsif os =~ /Opera Mini/
    true
  elsif os =~ /BlackBerry/
    true
  elsif os =~ /RIM/
    true
  elsif browser =~ /Nokia/
    true
  elsif application && application.comment &&
      application.comment.detect { |k, v| k =~ /^IEMobile/ }
    true
  else
    false
  end
end

#osObject



43
44
45
# File 'lib/user_agent/browsers/all.rb', line 43

def os
  nil
end

#platformObject



39
40
41
# File 'lib/user_agent/browsers/all.rb', line 39

def platform
  nil
end

#respond_to?(symbol) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/user_agent/browsers/all.rb', line 47

def respond_to?(symbol)
  detect_product(symbol) ? true : super
end

#to_sObject



19
20
21
# File 'lib/user_agent/browsers/all.rb', line 19

def to_s
  to_str
end

#to_strObject



23
24
25
# File 'lib/user_agent/browsers/all.rb', line 23

def to_str
  join(" ")
end

#versionObject



35
36
37
# File 'lib/user_agent/browsers/all.rb', line 35

def version
  application && application.version
end

#webkit?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/user_agent/browsers/all.rb', line 55

def webkit?
  false
end