Module: ActionController::MobileFu::InstanceMethods
- Defined in:
- lib/mobile-fu.rb
Instance Method Summary (collapse)
-
- (Object) force_mobile_format
Forces the request format to be :mobile.
-
- (Boolean) in_mobile_view?
Returns either true or false depending on whether or not the format of the request is either :mobile or not.
-
- (Boolean) is_device?(type)
Can check for a specific user agent e.g., is_device?('iphone') or is_device?('mobileexplorer').
-
- (Boolean) is_mobile_device?
Returns either true or false depending on whether or not the user agent of the device making the request is matched to a device in our regex.
-
- (Object) set_mobile_format
Determines the request format based on whether the device is mobile or if the user has opted to use either the 'Standard' view or 'Mobile' view.
Instance Method Details
- (Object) force_mobile_format
Forces the request format to be :mobile
61 62 63 64 |
# File 'lib/mobile-fu.rb', line 61 def force_mobile_format request.format = :mobile session[:mobile_view] = true if session[:mobile_view].nil? end |
- (Boolean) in_mobile_view?
Returns either true or false depending on whether or not the format of the request is either :mobile or not.
79 80 81 |
# File 'lib/mobile-fu.rb', line 79 def in_mobile_view? request.format.to_sym == :mobile end |
- (Boolean) is_device?(type)
Can check for a specific user agent e.g., is_device?('iphone') or is_device?('mobileexplorer')
93 94 95 |
# File 'lib/mobile-fu.rb', line 93 def is_device?(type) request.user_agent.to_s.downcase.include?(type.to_s.downcase) end |
- (Boolean) is_mobile_device?
Returns either true or false depending on whether or not the user agent of the device making the request is matched to a device in our regex.
86 87 88 |
# File 'lib/mobile-fu.rb', line 86 def is_mobile_device? request.user_agent.to_s.downcase =~ Regexp.new(ActionController::MobileFu::MOBILE_USER_AGENTS) end |
- (Object) set_mobile_format
Determines the request format based on whether the device is mobile or if the user has opted to use either the 'Standard' view or 'Mobile' view.
69 70 71 72 73 74 |
# File 'lib/mobile-fu.rb', line 69 def set_mobile_format if is_mobile_device? && !request.xhr? request.format = session[:mobile_view] == false ? :html : :mobile session[:mobile_view] = true if session[:mobile_view].nil? end end |