lib/action_view/helpers/css_browser_selector.rb
def determine_browser_and_os(ua = request.env["HTTP_USER_AGENT"])
        ua = (ua||"").downcase
        br = case ua
          when /opera[\/,\s+](\d+)/
            o = %W(opera opera#{$1})
            o << "mobile" if ua.include?('mini')
            o.join(" ")
          when /webtv/ ;              "gecko"
          when /msie (\d)/ ;          "ie ie#{$1}"
          when %r{firefox/2} ;        "gecko ff2"
          when %r{firefox/3.5} ;      "gecko ff3 ff3_5"
          when %r{firefox/3} ;        "gecko ff3"
          when /konqueror/ ;          "konqueror"
          when /applewebkit\/([\d.]+).? \([^)]*\) ?(?:version\/(\d+))?.*$/
            o = %W(webkit)
            if ua.include?('iron')
              o << 'iron'
            elsif ua.include?('chrome')
              o << 'chrome'
            else
              o << "safari safari"+ ($2 || (($1.to_i >= 400) ? '2' : '1'))
            end
            o.join(" ")
          when /gecko/, /mozilla/ ;   "gecko"
        end
        os = ua.include?('mac') || ua.include?('darwin') ? ua.include?('iphone') ? 'iphone' : ua.include?('ipod') ? 'ipod' : 'mac' :
             ua.include?('x11') || ua.include?('linux') ? 'linux' :
             ua.include?('win') ? 'win' : nil
        "#{br}#{" " unless br.nil? or os.nil?}#{os}"
      end
# The ruby version of the CSS Browser Selector with some additions
# TODO: This should be moved to a parser.
The ruby version of the CSS Browser Selector with some additions
TODO: This should be moved to a parser.
The ruby version of the CSS Browser Selector with some additions TODO : This should be moved to a parser .
def determine_browser_and_os(ua = request.env["HTTP_USER_AGENT"])
        ua = (ua||"").downcase
        br = case ua
          when /opera[\/,\s+](\d+)/
            o = %W(opera opera#{$1})
            o << "mobile" if ua.include?('mini')
            o.join(" ")
          when /webtv/ ;              "gecko"
          when /msie (\d)/ ;          "ie ie#{$1}"
          when %r{firefox/2} ;        "gecko ff2"
          when %r{firefox/3.5} ;      "gecko ff3 ff3_5"
          when %r{firefox/3} ;        "gecko ff3"
          when /konqueror/ ;          "konqueror"
          when /applewebkit\/([\d.]+).? \([^)]*\) ?(?:version\/(\d+))?.*$/
            o = %W(webkit)
            if ua.include?('iron')
              o << 'iron'
            elsif ua.include?('chrome')
              o << 'chrome'
            else
              o << "safari safari"+ ($2 || (($1.to_i >= 400) ? '2' : '1'))
            end
            o.join(" ")
          when /gecko/, /mozilla/ ;   "gecko"
        end
        os = ua.include?('mac') || ua.include?('darwin') ? ua.include?('iphone') ? 'iphone' : ua.include?('ipod') ? 'ipod' : 'mac' :
             ua.include?('x11') || ua.include?('linux') ? 'linux' :
             ua.include?('win') ? 'win' : nil
        "#{br}#{" " unless br.nil? or os.nil?}#{os}"
      end
def determine_browser_and_os ( ua = request . env [ "HTTP_USER_AGENT" ] ) ua = ( ua || "" ) . downcase br = case ua when / opera[ \/ , \s +]( \d +) / o = %W( opera opera #{ $1 } ) o << "mobile" if ua . include? ( 'mini' ) o . join ( " " ) when / webtv / ; "gecko" when / msie ( \d ) / ; "ie ie#{$1}" when %r{ firefox/2 } ; "gecko ff2" when %r{ firefox/3.5 } ; "gecko ff3 ff3_5" when %r{ firefox/3 } ; "gecko ff3" when / konqueror / ; "konqueror" when / applewebkit \/ ([ \d .]+).?  \( [^)]* \)  ?(?:version \/ ( \d +))?.*$ / o = %W( webkit ) if ua . include? ( 'iron' ) o << 'iron' elsif ua . include? ( 'chrome' ) o << 'chrome' else o << "safari safari" + ( $2 || ( ( $1 . to_i >= 400 ) ? '2' : '1' ) ) end o . join ( " " ) when / gecko / , / mozilla / ; "gecko" end os = ua . include? ( 'mac' ) || ua . include? ( 'darwin' ) ? ua . include? ( 'iphone' ) ? 'iphone' : ua . include? ( 'ipod' ) ? 'ipod' : 'mac' : ua . include? ( 'x11' ) || ua . include? ( 'linux' ) ? 'linux' : ua . include? ( 'win' ) ? 'win' : nil "#{br}#{" " unless br.nil? or os.nil?}#{os}" end
The ruby version of the CSS Browser Selector with some additions
TODO: This should be moved to a parser.
The ruby version of the CSS Browser Selector with some additions TODO : This should be moved to a parser .
ua
request
env