RubyMotion
Making iOS apps in Ruby
@pd_i
Prerequisites
Prerequisites


  Ruby MVC
      Objective-C*
                     *optional
What is
RubyMotion?
Ruby toolchain for iOS
Author:
Laurent Sansonetti

(MacRuby)
1.9
compliant
Something
    Objective-C
Objective-C Runtime
Foundation Framework

     iOS SDK
RubyMotion   Objective-C

Objective-C Runtime
Foundation Framework

       iOS SDK
Different...
...but the same

        Gary
       Oldman
Observations
Objects
RubyMotion
Objective-C
RubyMotion Objects
# Ruby
"PHRUG".class.ancestors
=> [String, Comparable, Object, Kernel,
BasicObject]

# RubyMotion
"PHRUG".class.ancestors
=> [String, NSMutableString, NSString,
Comparable, NSObject, Kernel]
RubyMotion Objects
# RubyMotion
Object == NSObject
=> true
Objective-C
RubyMotion    Methods
RubyMotion Methods
# Objective-C / Cocoa
NSString *string =
 [[NSString alloc] initWithString:@"PhRuG"];

# RubyMotion
string =
  NSString.alloc.initWithString "PhRuG"
RubyMotion Methods
# Objective-C / Cocoa
NSString *string =
  [[NSString alloc] initWithString:@"PhRuG"];
[string uppercaseString] => "PHRUG";
# RubyMotion
string =
  NSString.alloc.initWithString "PhRuG"
string.uppercaseString => "PHRUG"
RubyMotion Methods
# Objective-C / Cocoa
NSString *string =
  [[NSString alloc] initWithString:@"PhRuG"];
[string uppercaseString] => "PHRUG";
# RubyMotion
string =
  NSString.alloc.initWithString "PhRuG"
string.uppercaseString => "PHRUG"
# we can still use ruby methods!
string.upcase            => "PHRUG"
Named
Parameters
Named Parameters
# Objective-C, named parameters
[string drawAtPoint: point withFont:font]
# RubyMotion
string.drawAtPoint(point, withFont:font)
# using send
string
   .send(:"drawAtPoint:withFont:", point, font)
Named Parameters
# Objective-C, named parameters
[string drawAtPoint: point withFont:font]
# RubyMotion
string.drawAtPoint(point, withFont:font)
# using send
string
   .send(:"drawAtPoint:withFont:", point, font)
If they're the
   same...
... why use it?
Good
Stuff
Power
Editor
   +
Terminal
Rake
rake simulator
rake device
rake spec
Testing
 (MacBacon)
Garbage
Collection
REPL
(read-eval-print loop)
DSLs
(domain specific languages)
Cocoapods
Disadvantages
Disadvantages
● Cost
  ○ $199.99 with 1 year updates
  ○ $99 per year to continue updates
● Most resources are in Objective-C
● Not an excuse to not learn Objective-C
● No RubyMotion Book (yet)
Demo Time!
Questions?
Resources
● rubymotion.com
● rubymotion.com/developer-center
● slideshare.net/markvilla/macruby-rubymotion-
    madridrb-may-2012-13154591
●   http://www.slideshare.net/clayallsopp/preview-
    unicorns-magic-and-better-apps-with-rubymotion [for
    the Gary Oldman metaphor :) ]
Images
● http://rubyidentity.org/
● http://www.rubymotion.com/press/
● developer.apple.
  com/technologies/mac/cocoa.html
● cocoapods.org
Thanks!
Marc Ignacio
twitter: @pd_i   github: @padi
RubyMotion Introduction

RubyMotion Introduction