module Jpmobile::RequestWithMobile
Public Instance Methods
mobile()
click to toggle source
携帯電話の機種に応じて Mobile::xxx を返す。 携帯電話でない場合はnilを返す。
# File lib/jpmobile/request_with_mobile.rb, line 49 def mobile env['rack.jpmobile'] end
mobile?()
click to toggle source
携帯電話からであれば true
を、そうでなければ false
を返す。
# File lib/jpmobile/request_with_mobile.rb, line 33 def mobile? mobile and !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) __send__(:remote_ip) # for Rails elsif respond_to?(:ip) __send__(:ip) # for Rack else if env['HTTP_X_FORWARDED_FOR'] env['HTTP_X_FORWARDED_FOR'].split(',').pop else env['REMOTE_ADDR'] end end end
smart_phone?()
click to toggle source
viewの切り替えをするかどうか
# File lib/jpmobile/request_with_mobile.rb, line 38 def smart_phone? mobile and mobile.smart_phone? end
tablet?()
click to toggle source
タブレットからであれば true
を、そうでなければ false
を返す
# File lib/jpmobile/request_with_mobile.rb, line 43 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 28 def user_agent=(str) self.env['HTTP_USER_AGENT'] = str end