ext/pdf417/pdf417.c
/*
 * call-seq:
 *   encode_text(text)
 *
 * Returns an array of integers showing the codewords
 */


Returns an array of integers showing the codewords
Returns an array of integers showing the codewords
static VALUE rb_pdf417_lib_encode_text(VALUE self, VALUE text) {
  Check_Type(text, T_STRING);
  VALUE list;
  int k;
  pdf417param p;
  pdf417init(&p);
  p.text = StringValuePtr(text);
  p.lenText = (int)RSTRING_LEN(text);
  if(p.lenText == 0){
    return rb_ary_new2(0);
  }
  fetchCodewords(&p);
  if (p.error) {
      pdf417free(&p);
      return Qnil; 
  }
  list = rb_ary_new2(p.lenCodewords);
  pdf417free(&p); 
  for (k = 0; k < p.lenCodewords; ++k) {
    rb_ary_push(list, INT2NUM(p.codewords[k]));
  }
  return list;
}
static VALUE rb_pdf417_lib_encode_text ( VALUE self , VALUE text ) { Check_Type ( text , T_STRING ) ; VALUE list ; int k ; pdf417param p ; pdf417init ( & p ) ; p . text = StringValuePtr ( text ) ; p . lenText = ( int ) RSTRING_LEN ( text ) ; if ( p . lenText == 0 ) { return rb_ary_new2 ( 0 ) ; } fetchCodewords ( & p ) ; if ( p . error ) { pdf417free ( & p ) ; return Qnil ; } list = rb_ary_new2 ( p . lenCodewords ) ; pdf417free ( & p ) ; for ( k = 0 ; k < p . lenCodewords ; ++ k ) { rb_ary_push ( list , INT2NUM ( p . codewords [ k ] ) ) ; } return list ; }
call-seq:
   encode_text(text)
call - seq : encode_text ( text )
//could also return list or raise something