Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save walf443/3114 to your computer and use it in GitHub Desktop.
Save walf443/3114 to your computer and use it in GitHub Desktop.
diff --git a/lib/jpmobile/request_with_mobile.rb b/lib/jpmobile/request_with_mobile.rb
index e6f944c..720e646 100644
--- a/lib/jpmobile/request_with_mobile.rb
+++ b/lib/jpmobile/request_with_mobile.rb
@@ -24,8 +24,16 @@ module Jpmobile
end
# 携帯電話からであれば +true+を、そうでなければ +false+ を返す。
- def mobile?
- mobile != nil
+ # 引数にキャリア名(:docomo, :au など)を指定することで、モバイルであったときにさらにキャリアかどうかの判別ができる
+ def mobile?(career=nil)
+ return false if mobile.nil?
+
+ if career
+ return mobile.__send__("#{career.to_s}?")
+ else
+ return true
+ end
+ end
end
# 携帯電話の機種に応じて Mobile::xxx を返す。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment