Module: Browser::IE

Included in:
Browser
Defined in:
lib/browser/methods/ie.rb

Constant Summary collapse

TRIDENT_VERSION_REGEX =
%r[Trident/([0-9.]+)]
MODERN_IE =
%r[Trident/.*?; rv:(.*?)]
MSIE =
%r{MSIE ([\d.]+)|Trident/.*?; rv:([\d.]+)}
EDGE =
%r{(Edge/[\d.]+|Trident/8)}
TRIDENT_MAPPING =
{
  "4.0" => "8",
  "5.0" => "9",
  "6.0" => "10",
  "7.0" => "11",
  "8.0" => "12"
}

Instance Method Summary collapse

Instance Method Details

#compatibility_view?Boolean

Detect if IE is running in compatibility mode.

Returns:

  • (Boolean)


79
80
81
# File 'lib/browser/methods/ie.rb', line 79

def compatibility_view?
  ie? && trident_version && msie_version.to_i < (trident_version.to_i + 4)
end

#edge?Boolean

Detect if browser is Microsoft Edge.

Returns:

  • (Boolean)


74
75
76
# File 'lib/browser/methods/ie.rb', line 74

def edge?
  !!(ua =~ EDGE)
end

#ie10?Boolean

Detect if browser is Internet Explorer 10.

Returns:

  • (Boolean)


64
65
66
# File 'lib/browser/methods/ie.rb', line 64

def ie10?
  ie? && version == "10"
end

#ie11?Boolean

Detect if browser is Internet Explorer 11.

Returns:

  • (Boolean)


69
70
71
# File 'lib/browser/methods/ie.rb', line 69

def ie11?
  ie? && version == "11"
end

#ie6?Boolean

Detect if browser is Internet Explorer 6.

Returns:

  • (Boolean)


44
45
46
# File 'lib/browser/methods/ie.rb', line 44

def ie6?
  ie? && version == "6"
end

#ie7?Boolean

Detect if browser is Internet Explorer 7.

Returns:

  • (Boolean)


49
50
51
# File 'lib/browser/methods/ie.rb', line 49

def ie7?
  ie? && version == "7"
end

#ie8?Boolean

Detect if browser is Internet Explorer 8.

Returns:

  • (Boolean)


54
55
56
# File 'lib/browser/methods/ie.rb', line 54

def ie8?
  ie? && version == "8"
end

#ie9?Boolean

Detect if browser is Internet Explorer 9.

Returns:

  • (Boolean)


59
60
61
# File 'lib/browser/methods/ie.rb', line 59

def ie9?
  ie? && version == "9"
end

#ie?Boolean

Detect if browser is Internet Explorer.

Returns:

  • (Boolean)


39
40
41
# File 'lib/browser/methods/ie.rb', line 39

def ie?
  msie? || modern_ie?
end

#ie_full_versionObject



21
22
23
# File 'lib/browser/methods/ie.rb', line 21

def ie_full_version
  "#{ie_version}.0"
end

#ie_versionObject



17
18
19
# File 'lib/browser/methods/ie.rb', line 17

def ie_version
  TRIDENT_MAPPING[trident_version] || msie_version
end

#msie_full_versionObject



25
26
27
# File 'lib/browser/methods/ie.rb', line 25

def msie_full_version
  (ua.match(MSIE) && ($1 || $2)) || "0.0"
end

#msie_versionObject



29
30
31
# File 'lib/browser/methods/ie.rb', line 29

def msie_version
  msie_full_version.to_s.split(".").first || "0"
end

#trident_versionObject

Return the trident version.



34
35
36
# File 'lib/browser/methods/ie.rb', line 34

def trident_version
  ua.match(TRIDENT_VERSION_REGEX) && $1
end