Reputation: 20538
I am developing a Rubymotion app. I am using the pod KNSemiModalViewController. How can I "translate" this Objective-C code into ruby?
[self presentSemiViewController:semiVC withOptions:@{
KNSemiModalOptionKeys.pushParentBack : @(YES),
KNSemiModalOptionKeys.animationDuration : @(0.3),
KNSemiModalOptionKeys.shadowOpacity : @(0.8),
}];
Upvotes: 0
Views: 228
Reputation: 321
I've seen a Sublime plugin objc2rubymotion, never tried.
There is a web page based on it http://objc2rubymotion.herokuapp.com
Never tried as well but it might help rubyists falling down in iOS environment like me :)
Upvotes: -2
Reputation: 61
self.presentSemiViewController(semiVC, withOptions:{
KNSemiModalOptionKeys.pushParentBack => true,
KNSemiModalOptionKeys.animationDuration => 0.3,
KNSemiModalOptionKeys.shadowOpacity => 0.8
})
Upvotes: 1
Reputation: 162712
You'll have to work out the Ruby side of things yourself, but this line of code:
[self presentSemiViewController:semiVC withOptions:@{
KNSemiModalOptionKeys.pushParentBack : @(YES),
KNSemiModalOptionKeys.animationDuration : @(0.3),
KNSemiModalOptionKeys.shadowOpacity : @(0.8),
}];
Is the same as this:
NSDictionary *dict = [NSDictionary, dictionaryWithObjectsAndKeys:
[NSNumber numberWithBOOL:YES], KNSemiModalOptionKeys.pushParentBack,
[NSNumber numberWithFloat:0.3], KNSemiModalOptionKeys.animationDuration,
[NSNumber numberWithFloat:08], KNSemiModalOptionKeys.shadowOpacity];
[self presentSemiViewController:semiVC withOptions:dict];
Assuming that KNSemiModalOptionKeys.pushParentBack
is using dot notation to execute a method, each of those could be rewritten as [KNSemiModalOptionKeys pushParentBack]
.
Hopefully, that gives you enough info on the ObjC side to translate to Ruby (which is quite adept at forming dictionaries, IIRC).
Upvotes: 2