toshimaru/rack-simple_user_agent

View on GitHub
lib/rack/simple_user_agent/detectors/android.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module Rack
  class SimpleUserAgent
    module Detectors
      module Android
        def from_android?
          user_agent_string.include?('Android')
        end

        def from_android_tablet?
          from_android? && !android_mobile?
        end

        def from_android_mobile?
          from_android? && android_mobile?
        end

        private

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