Presented on 8/14/2012 at BostonRb. This talk provides a nice intro and overview of what RubyMotion is and whether or not it's worth incorporating into your development toolkit.
36. So What Does it Do?
✦ Ruby!!! (NO OBJECTIVE-C!)
✦ Keep Your Editor (NO XCODE!)
37. So What Does it Do?
✦ Ruby!!! (NO OBJECTIVE-C!)
✦ Keep Your Editor (NO XCODE!)
✦ IRB
38. So What Does it Do?
✦ Ruby!!! (NO OBJECTIVE-C!)
✦ Keep Your Editor (NO XCODE!)
✦ IRB
✦ Terminal Based Workflow (Rake)
39. So What Does it Do?
✦ Ruby!!! (NO OBJECTIVE-C!)
✦ Keep Your Editor (NO XCODE!)
✦ IRB
✦ Terminal Based Workflow (Rake)
✦ Testing Framework (MacBacon)
40. So What Does it Do?
✦ Ruby!!! (NO OBJECTIVE-C!) ✦ Native Applications
✦ Keep Your Editor (NO XCODE!)
✦ IRB
✦ Terminal Based Workflow (Rake)
✦ Testing Framework (MacBacon)
41. So What Does it Do?
✦ Ruby!!! (NO OBJECTIVE-C!) ✦ Native Applications
✦ Keep Your Editor (NO XCODE!) ✦ App Store Approved
✦ IRB
✦ Terminal Based Workflow (Rake)
✦ Testing Framework (MacBacon)
47. def tableView(tableView, didSelectRowAtIndexPath: indexPath)
# do something
end
def tableView(tableView, numberOfRowsInSection: section)
# do something
end
def tableView(tableView, cellForRowAtIndexPath: indexPath)
# do something
end
50. HTTP
data = {first_name: 'Matt', last_name: 'Aimonetti'}
BubbleWrap::HTTP.post("http://foo.bar.com/", {payload: data}) do |response|
if response.ok?
json = BubbleWrap::JSON.parse(response.body.to_str)
p json['id']
elsif response.status_code.to_s =~ /40d/
App.alert("Login failed")
else
App.alert(response.error_message)
end
end
51. App
> App.documents_path
# "~/iPhone Simulator/5.0/Applications/EEC6454E-1816-451E-BB9A-EE18222E1A8F/Documents"
> App.resources_path
# "~/iPhone Simulator/5.0/Applications/EEC64-1816-451E-BB9A-EE18221A8F/testSuite_spec.app"
> App.name
# "testSuite"
> App.identifier
# "io.bubblewrap.testSuite"
> App.alert("BubbleWrap is awesome!")
# creates and shows an alert message.
> App.run_after(0.5) { p "It's #{Time.now}" }
# Runs the block after 0.5 seconds.
> App.open_url("http://matt.aimonetti.net")
# Opens the url using the device's browser. (accepts a string url or an instance of NSURL.
> App::Persistence['channels'] # application specific persistence storage
# ['NBC', 'ABC', 'Fox', 'CBS', 'PBS']
> App::Persistence['channels'] = ['TF1', 'France 2', 'France 3']
# ['TF1', 'France 2', 'France 3']
53. Camera
# Uses the front camera
BW::Device.camera.front.picture(media_types: [:movie, :image]) do |result|
image_view = UIImageView.alloc.initWithImage(result[:original_image])
end
# Uses the rear camera
BW::Device.camera.rear.picture(media_types: [:movie, :image]) do |result|
image_view = UIImageView.alloc.initWithImage(result[:original_image])
end
# Uses the photo library
BW::Device.camera.any.picture(media_types: [:movie, :image]) do |result|
image_view = UIImageView.alloc.initWithImage(result[:original_image])
end
55. Media
# Plays in your custom frame
local_file = NSURL.fileURLWithPath(File.join(NSBundle.mainBundle.resourcePath, 'test.mp3'))
BW::Media.play(local_file) do |media_player|
media_player.view.frame = [[10, 100], [100, 100]]
self.view.addSubview media_player.view
end
# Plays in an independent modal controller
BW::Media.play_modal("http://www.hrupin.com/wp-content/uploads/mp3/testsong_20_sec.mp3")