This project was initiated by Yuichiro MASUI, which is used by Appcelerator. Appcelerator is a company that provides a mobile platform development framework. Its Titanium development framework allows developers to develop mobile applications in familiar languages.
MobiRuby is built based on mruby (a lightweight Ruby language implementation that can run Ruby code in interpreted mode and run it in a virtual machine. Yuichiro MASUI hopes to use this framework to enable Ruby to develop mobile applications instead of the Objective-C/Java language, just like Lua or Mono.
Currently, this project has only one sample code and Yuichiro said that the first version will be released in the next few months and will be based on the Apache 2.0 license agreement.
MobiRuby example:
Ruby code:
- # UIAlertView demo
- def _S(str)
- NSString._stringWithUTF8String(str)
- end
- class MyAlertView < Mobi::Cocoa::UIAlertView
- define :void, :didPresentAlertView, :id do
- p "MyAlertView::didPresentAlertView"
- end
- define :void, :alertView, :id, :clickedButtonAtIndex, :int do |me, index|
- if index == 1
- app = UIApplication._sharedApplication
- url = NSURL._URLWithString(_S("http://mobiruby.org"))
- app._openURL url
- end
- end
- end
- alert = MyAlertView._alloc.
- _initWithTitle _S("Hello"),
- :message, _S("I'm MobiRuby"),
- :delegate, nil,
- :cancelButtonTitle, _S("I know!"),
- :otherButtonTitles, _S("What's?"), nil
Running result: