Class: RubyMotionQuery::Device
- Inherits:
-
Object
- Object
- RubyMotionQuery::Device
- Defined in:
- motion/ruby_motion_query/device.rb
Constant Summary
- ORIENTATIONS =
{ UIDeviceOrientationUnknown => :unkown, UIDeviceOrientationPortrait => :portrait, UIDeviceOrientationPortraitUpsideDown => :portrait_upside_down, UIDeviceOrientationLandscapeLeft => :landscape_Left, UIDeviceOrientationLandscapeRight => :landscape_right, UIDeviceOrientationFaceUp => :face_up, UIDeviceOrientationFaceDown => :face_down }
Class Method Summary (collapse)
- + (Boolean) four_inch?
- + (Numeric) height
- + (Boolean) ipad?
- + (Boolean) iphone?
- + (Boolean) landscape?
-
+ (Object) orientation
:unknown or from ORIENTATIONS.
- + (Boolean) portrait?
- + (Boolean) retina?
- + (UIScreen) screen
- + (Boolean) simulator?
- + (Numeric) width
Class Method Details
+ (Boolean) four_inch?
45 46 47 48 |
# File 'motion/ruby_motion_query/device.rb', line 45 def four_inch? @_four_inch = (Device.height == 568.0) if @_four_inch.nil? @_four_inch end |
+ (Numeric) height
27 28 29 |
# File 'motion/ruby_motion_query/device.rb', line 27 def height @_height ||= Device.screen.bounds.size.height end |
+ (Boolean) ipad?
31 32 33 34 |
# File 'motion/ruby_motion_query/device.rb', line 31 def ipad? @_ipad = (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) if @_ipad.nil? @_ipad end |
+ (Boolean) iphone?
36 37 38 39 |
# File 'motion/ruby_motion_query/device.rb', line 36 def iphone? @_iphone = (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone) if @_iphone.nil? @_iphone end |
+ (Boolean) landscape?
64 65 66 |
# File 'motion/ruby_motion_query/device.rb', line 64 def landscape? Device.orientation == :landscape_Left || Device.orientation == :landscape_right end |
+ (Object) orientation
Returns :unknown or from ORIENTATIONS
60 61 62 |
# File 'motion/ruby_motion_query/device.rb', line 60 def orientation ORIENTATIONS[UIDevice.currentDevice.orientation] || :unknown end |
+ (Boolean) portrait?
68 69 70 |
# File 'motion/ruby_motion_query/device.rb', line 68 def portrait? Device.orientation == :portrait || Device.orientation == :unknown end |
+ (Boolean) retina?
50 51 52 53 54 55 56 57 |
# File 'motion/ruby_motion_query/device.rb', line 50 def retina?() if @_retina.nil? main_screen = Device.screen @_retina = !!(main_screen.respondsToSelector('displayLinkWithTarget:selector:') && main_screen.scale == 2.0) end @_retina end |
+ (UIScreen) screen
17 18 19 |
# File 'motion/ruby_motion_query/device.rb', line 17 def screen UIScreen.mainScreen end |
+ (Boolean) simulator?
41 42 43 |
# File 'motion/ruby_motion_query/device.rb', line 41 def simulator? @_simulator ||= !(UIDevice.currentDevice.model =~ /simulator/i).nil? end |
+ (Numeric) width
22 23 24 |
# File 'motion/ruby_motion_query/device.rb', line 22 def width @_width ||= Device.screen.bounds.size.width end |