lib/bad_browser/user_agent.rb
# Main driver of user-agent detection. This method will run a bunch of RegExs to try and match
# the supplied string. It matches from most popular to least popular with the exception of
# Opera. We have to check for opera first (via String#include?) and "jump" away since
# Opera tries to disguise itself as MSIE and Firefox sometimes.
Main driver of user-agent detection. This method will run a bunch of RegExs to try and match
the supplied string. It matches from most popular to least popular with the exception of
Opera. We have to check for opera first (via String#include?) and "jump" away since
Opera tries to disguise itself as MSIE and Firefox sometimes.
Main driver of user - agent detection . This method will run a bunch of RegExs to try and match the supplied string . It matches from most popular to least popular with the exception of Opera . We have to check for opera first ( via String#include? ) and " jump " away since Opera tries to disguise itself as MSIE and Firefox sometimes .
def detect_user_agent
    return match_opera if @string.include?('Opera')
    match_with(:msie, /MSIE[ ]*(\d{1,2}\.[\dbB]{1,3})*|Trident\/[0-9\.]+;[ ]*rv (\d{2}\.\d{1,2})/)      or
    match_with(:firefox, /Firefox[ \(\/]*([a-z0-9\.\-\+]*)/i) or
    match_with(:chrome, /Chrome\/([\d\.]+)*/)                 or
    match_safari
  end
def detect_user_agent return match_opera if @string . include? ( 'Opera' ) match_with ( :msie , / MSIE[ ]*( \d {1,2} \. [ \d bB]{1,3})*|Trident \/ [0-9 \. ]+;[ ]*rv ( \d {2} \. \d {1,2}) / ) or match_with ( :firefox , / Firefox[  \( \/ ]*([a-z0-9 \. \- \+ ]*) /i ) or match_with ( :chrome , / Chrome \/ ([ \d \. ]+)* / ) or match_safari end
Main driver of user-agent detection.
Main driver of user - agent detection .
# "jump away" for Opera using String#include? since it's quicker than regex at this point