Sha256: c25c1d2d020efc6055aafac3a9772409bb5de03a4ead2b89d2b3a34d268eb67e

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

#include <ruby.h>

/* our new native method; it just returns
 * the string "bonjour!" */
static VALUE calc_bonjour(VALUE self) {
  return rb_str_new2("bonjour!");
}

/* ruby calls this to load the extension */
void Init_calc(void) {
  /* assume we haven't yet defined Hola */
  VALUE klass = rb_define_class("Calc_c",
      rb_cObject);

  /* the hola_bonjour function can be called
   * from ruby as "Hola.bonjour" */
  rb_define_singleton_method(klass,
      "bonjour", calc_bonjour, 0);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calc-nik-0.0.4 ext/calc/calc.c