Sha256: 2e47b6799abb8d3f1dccfb44b33d0a78baff443437c736cdaf067d92a6e1ae28

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

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

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

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

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

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

      def from_android?
        user_agent.to_s.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.to_s.include?("Windows Phone")
      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.2 lib/rack/simple_user_agent/detector.rb