Class: HalloWelt
- Inherits:
-
Object
- Object
- HalloWelt
- Defined in:
- lib/hallo_welt/version.rb
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Method Summary collapse
Instance Method Details
#hello ⇒ Object
3 4 5 6 |
# File 'ext/hallo_welt/hallo_welt.c', line 3 static VALUE hallo_welt_hello(VALUE self) { VALUE string = rb_str_new2("Hello World!"); return rb_funcall(self, rb_intern("print"), 1, string); } |
#print(obj) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'ext/hallo_welt/hallo_welt.c', line 8
static VALUE hallo_welt_print(VALUE self, VALUE obj) {
VALUE printable = rb_funcall(obj, rb_intern("to_s"), 0);
switch (TYPE(printable)) {
case T_STRING:
printf("%s\n", RSTRING_PTR(printable));
break;
default:
rb_raise(rb_eTypeError, "Could not obtain a valid String!");
break;
}
return Qnil;
}
|