Class: CFromRuby::NativeHelpers
- Inherits:
-
Object
- Object
- CFromRuby::NativeHelpers
- Defined in:
- ext/extension.c
Class Method Summary collapse
Class Method Details
.boolean(value) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'ext/extension.c', line 21
static VALUE boolean(VALUE self, VALUE value) {
int boolean_in = RTEST(value);
int boolean_out = boolean_from_library(boolean_in);
if (boolean_out == 1) {
return Qtrue;
} else {
return Qfalse;
}
}
|
.number(value) ⇒ Object
13 14 15 16 17 18 19 |
# File 'ext/extension.c', line 13
static VALUE number(VALUE self, VALUE value) {
Check_Type(value, T_FIXNUM);
int number_in = NUM2INT(value);
int number_out = number_from_library(number_in);
return INT2NUM(number_out);
}
|
.string(value) ⇒ Object
5 6 7 8 9 10 11 |
# File 'ext/extension.c', line 5
static VALUE string(VALUE self, VALUE value) {
Check_Type(value, T_STRING);
char* pointer_in = RSTRING_PTR(value);
char* pointer_out = string_from_library(pointer_in);
return rb_str_new2(pointer_out);
}
|