Sha256: 2e3396e3d54c691da36bd41b08b70cefc1d6222430a089ca335cbdda3aa38625

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

#include "ruby.h"
#include "intern.h"
#include <charguess.h>


static VALUE mCharGuess;

static VALUE cg_s_guess(VALUE klass, VALUE str) {
  const char*ptr;
  int ret;
  Check_Type(str, T_STRING);
  ret = CharGuessInit();
  ptr = GuessChardet((const char *)RSTRING(str)->ptr);
  ret = CharGuessDone();
  return ptr ? rb_str_new2(ptr) : Qnil;
}

void Init_charguess()
{
  ID id;
  
  id = rb_intern("CharGuess");
  if (rb_const_defined(rb_cObject, id)) {
    mCharGuess = rb_const_get(rb_cObject, id);
  } else {
    mCharGuess = rb_define_module("CharGuess");
  }
  rb_define_module_function(mCharGuess, "guess", cg_s_guess, 1);
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
charguess-1.3 ext/charguess/charguess.c
charguess-1.2 ext/charguess/charguess.c
charguess-1.1 ext/charguess/charguess.c
charguess-1.0 ext/charguess/charguess.c