Sha256: 30e0bd17e14309252631c7bbc0b559cb41d8b67c3717352eac79ce513a3744a1

Contents?: true

Size: 592 Bytes

Versions: 5

Compression:

Stored size: 592 Bytes

Contents

require "rack/request"

module Galakei
  module Request
    def docomo?
      /DoCoMo/i =~ user_agent
    end

    def au?
      # doesn't detect some 2G phones, but as they will be discontinued soon, doesn't really matter
      /KDDI/ =~ user_agent
    end

    def softbank?
      /^(SoftBank|Vodafone)/ =~ user_agent
    end

    def imode_browser_1_0?
      if /docomo(.*\((.*;)?c(\d+)\;)?/i =~ user_agent
        $3.to_i < 500
      else
        false
      end
    end

    def galakei?
      docomo? || au? || softbank?
    end
  end
end

Rack::Request.send :include, Galakei::Request

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
galakei-0.6.2 lib/galakei/request.rb
galakei-0.6.1 lib/galakei/request.rb
galakei-0.6.0 lib/galakei/request.rb
galakei-0.5.1 lib/galakei/request.rb
galakei-0.5.0 lib/galakei/request.rb