lib/browser_sniffer.rb in browser_sniffer-2.0.0 vs lib/browser_sniffer.rb in browser_sniffer-2.1.0
- old
+ new
@@ -87,10 +87,16 @@
browser_info[:version]
end
+ def in_app_browser
+ in_app_browser_info[:type]
+ end
+
+
+
def device
device_info[:name]
end
def device_name
@@ -119,10 +125,14 @@
def browser_info
@browser_info ||= parse_user_agent_for(BrowserSniffer::REGEX_MAP[:browser])
end
+ def in_app_browser_info
+ @in_app_browser_info = parse_user_agent_for(BrowserSniffer::REGEX_MAP[:in_app_browser])
+ end
+
def engine_info
@engine_info ||= parse_user_agent_for(BrowserSniffer::REGEX_MAP[:engine])
end
def device_info
@@ -133,12 +143,11 @@
@os_info ||= parse_user_agent_for(BrowserSniffer::REGEX_MAP[:os])
end
def parse_user_agent_for(type)
result = {}
- type.each_slice(2) do |slice|
- format = slice[1]
- slice[0].each do |regex|
+ type.each_slice(2) do |regexps, format|
+ regexps.each do |regex|
regex.match(user_agent) do |match|
format.each_with_index do |field, index|
if field.class == Symbol
result[field] = match[index + 1]
elsif field.class == Array