Sha256: ab9e448d3622406f38358145d12c2034fcc3838265c888d8368e6dc95e6774f3

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

module Rack
  class SimpleUserAgent
    module Detector
      def from_smartphone?
        from_ios? || from_android? || from_windows_phone?
      end

      def from_iphone?
        user_agent.include?("iPhone")
      end

      def from_ipad?
        user_agent.include?("iPad")
      end

      def from_ipod?
        user_agent.include?("iPod")
      end

      def from_ios?
        from_iphone? || from_ipad? || from_ipod?
      end

      def from_android?
        user_agent.include?("Android")
      end

      def from_android_tablet?
        from_android? && !android_mobile?
      end

      def from_android_mobile?
        from_android? && android_mobile?
      end

      def from_windows_phone?
        user_agent.include?("Windows Phone OS")
      end

      private

      def android_mobile?
        !(user_agent =~ /Android.+Mobi(le)?/).nil?
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-simple_user_agent-0.1.0 lib/rack/simple_user_agent/detector.rb