rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Added method to check if device has a physical camera. #336

Closed michaelkoper closed 10 years ago

michaelkoper commented 10 years ago

I was missing a method to check if there was a physical camera available (front or rear). This commit adds a method physical_camera? to the camera wrapper.

Device.camera.any? returns always true because it returns the photo library, which was kind of confusing for me.

markrickert commented 10 years ago

Is this needed in addition to Device.camera.front? and Device.camera.rear??

https://github.com/rubymotion/BubbleWrap/blob/master/motion/core/device/ios/camera.rb#L27-L35

michaelkoper commented 10 years ago

It is not really needed. It is just 1 function call instead of 2 which makes it more efficient.

clayallsopp commented 10 years ago

I'd be okay with this if it were named something like Device.camera.available?

michaelkoper commented 10 years ago

That is indeed a much better name :)

markrickert commented 10 years ago

:thumbsup:

michaelkoper commented 10 years ago

Thanks!