Module: BubbleWrap::Device

Defined in:
motion/core/device.rb,
motion/core/device/screen.rb

Defined Under Namespace

Modules: Screen

Class Method Summary (collapse)

Class Method Details

+ (TrueClass, FalseClass) front_camera?(picker = UIImagePickerController)

Verifies that the device running has a front facing camera.

Returns:

  • (TrueClass, FalseClass)

    true will be returned if the device has a front facing camera, false otherwise.



19
20
21
# File 'motion/core/device.rb', line 19

def front_camera?(picker=UIImagePickerController)
  picker.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceFront)
end

+ (TrueClass, FalseClass) ipad?(idiom = UIDevice.currentDevice.userInterfaceIdiom)

Verifies that the device running the app is an iPad.

Returns:

  • (TrueClass, FalseClass)

    true will be returned if the device is an iPad, false otherwise.



13
14
15
# File 'motion/core/device.rb', line 13

def ipad?(idiom=UIDevice.currentDevice.userInterfaceIdiom)
  idiom == UIUserInterfaceIdiomPad
end

+ (TrueClass, FalseClass) iphone?(idiom = UIDevice.currentDevice.userInterfaceIdiom)

Verifies that the device running the app is an iPhone.

Returns:

  • (TrueClass, FalseClass)

    true will be returned if the device is an iPhone, false otherwise.



7
8
9
# File 'motion/core/device.rb', line 7

def iphone?(idiom=UIDevice.currentDevice.userInterfaceIdiom)
  idiom == UIUserInterfaceIdiomPhone
end

+ (Object) orientation

Delegates to BubbleWrap::Screen.orientation



44
45
46
# File 'motion/core/device.rb', line 44

def orientation
  screen.orientation
end

+ (TrueClass, FalseClass) rear_camera?(picker = UIImagePickerController)

Verifies that the device running has a rear facing camera.

Returns:

  • (TrueClass, FalseClass)

    true will be returned if the device has a rear facing camera, false otherwise.



25
26
27
# File 'motion/core/device.rb', line 25

def rear_camera?(picker=UIImagePickerController)
  picker.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceRear)
end

+ (Boolean) retina?

Delegates to BubbleWrap::Screen.retina?

Returns:

  • (Boolean)


39
40
41
# File 'motion/core/device.rb', line 39

def retina?
  screen.retina?
end

+ (Object) screen

Shameless shorthand for accessing BubbleWrap::Screen



34
35
36
# File 'motion/core/device.rb', line 34

def screen
  BubbleWrap::Device::Screen
end

+ (Boolean) simulator?

Returns:

  • (Boolean)


29
30
31
# File 'motion/core/device.rb', line 29

def simulator?
  @simulator_state ||= !(UIDevice.currentDevice.model =~ /simulator/i).nil?
end