Skip to content

Instantly share code, notes, and snippets.

@sgonyea
Created October 28, 2010 22:35
Show Gist options
  • Save sgonyea/652485 to your computer and use it in GitHub Desktop.
Save sgonyea/652485 to your computer and use it in GitHub Desktop.
- (VALUE)toRuby {
switch ([self objCType]) {
case @encode(char):
case @encode(unsigned char): return CHR2FIX([self charValue]); break;
case @encode(short):
case @encode(long):
case @encode(int): return INT2FIX([self intValue]); break;
case @encode(unsigned short):
case @encode(unsigned long):
case @encode(unsigned int): return UINT2NUM([self unsignedIntValue]); break;
case @encode(unsigned float):
case @encode(float): return rb_float_new([self floatValue]); break;
case @encode(unsigned double):
case @encode(double): return rb_float_new([self doubleValue]); break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment