該項目由Yuichiro MASUI發起,此人為Appcelerator工作。Appcelerator是一家提供移動平台開發架構的公司,其Titanium開發架構允許開發人員使用自己熟悉的語言來開發行動裝置 App。
MobiRuby基於mruby(輕量級的Ruby語言實現,可使用解釋模式運行Ruby代碼並在虛擬機器中執行)構建。Yuichiro MASUI希望通過該架構,使Ruby能夠替代Objective-C/C/Java語言來開發行動裝置 App,就像Lua或Mono一樣。
目前,該項目只有一個程式碼範例和,Yuichiro稱,首個版本將在未來幾個月內發布,將基於Apache 2.0許可協議。
MobiRuby樣本:
Ruby代碼:
- # 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
運行結果: