module Jpmobile::RequestWithMobile
Public Instance Methods
mobile()
click to toggle source
携帯電話の機種に応じて Mobile::xxx を返す。 携帯電話でない場合はnilを返す。
# File lib/jpmobile/request_with_mobile.rb, line 45 def mobile env['rack.jpmobile'] end
mobile?()
click to toggle source
携帯電話からであれば true
を、そうでなければ false
を返す。
# File lib/jpmobile/request_with_mobile.rb, line 29 def mobile? mobile and not mobile.smart_phone? end
remote_addr()
click to toggle source
for reverse proxy.
# File lib/jpmobile/request_with_mobile.rb, line 13 def remote_addr if respond_to?(:remote_ip) return __send__(:remote_ip) # for Rails elsif respond_to?(:ip) return __send__(:ip) # for Rack else return ( env["HTTP_X_FORWARDED_FOR"] ? env["HTTP_X_FORWARDED_FOR"].split(',').pop : env["REMOTE_ADDR"] ) end end
smart_phone?()
click to toggle source
viewの切り替えをするかどうか
# File lib/jpmobile/request_with_mobile.rb, line 34 def smart_phone? mobile and mobile.smart_phone? end
tablet?()
click to toggle source
タブレットからであれば true
を、そうでなければ false
を返す
# File lib/jpmobile/request_with_mobile.rb, line 39 def tablet? mobile and mobile.tablet? end
user_agent()
click to toggle source
環境変数 HTTP_USER_AGENT を返す。
# File lib/jpmobile/request_with_mobile.rb, line 8 def user_agent env['HTTP_USER_AGENT'] end
user_agent=(str)
click to toggle source
環境変数 HTTP_USER_AGENT を設定する。
# File lib/jpmobile/request_with_mobile.rb, line 24 def user_agent=(str) self.env["HTTP_USER_AGENT"] = str end