Module: BubbleWrap::Device

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

Defined Under Namespace

Modules: CameraWrapper, Screen Classes: Camera

Class Method Summary collapse

Class Method Details

.cameraDevice::Camera::CameraWrapper

Use this to make a DSL-style call for picking images

Examples:

Device.camera.front

Returns:

  • (Device::Camera::CameraWrapper)


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

def camera
  BubbleWrap::Device::CameraWrapper
end

.front_camera?(picker = UIImagePickerController) ⇒ TrueClass, FalseClass

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.



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

def front_camera?(picker=UIImagePickerController)
  p "This method (front_camera?) is DEPRECATED. Transition to using Device.camera.front?"
  picker.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceFront)
end

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

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

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

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

.orientationObject

Delegates to BubbleWrap::Screen.orientation



53
54
55
# File 'motion/core/device.rb', line 53

def orientation
  screen.orientation
end

.rear_camera?(picker = UIImagePickerController) ⇒ TrueClass, FalseClass

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.



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

def rear_camera?(picker=UIImagePickerController)
  p "This method (rear_camera?) is DEPRECATED. Transition to using Device.camera.rear?"
  picker.isCameraDeviceAvailable(UIImagePickerControllerCameraDeviceRear)
end

.retina?Boolean

Delegates to BubbleWrap::Screen.retina?

Returns:

  • (Boolean)


48
49
50
# File 'motion/core/device.rb', line 48

def retina?
  screen.retina?
end

.screenObject

Shameless shorthand for accessing BubbleWrap::Screen



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

def screen
  BubbleWrap::Device::Screen
end

.simulator?Boolean

Returns:

  • (Boolean)


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

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