Class: Fixnum

Inherits:
Object show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#ffi_yajl(rb_yajl_gen, state) ⇒ Object



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'ext/ffi_yajl/ext/encoder/encoder.c', line 290

static VALUE rb_cFixnum_ffi_yajl(VALUE self, VALUE rb_yajl_gen, VALUE state) {
  VALUE str = rb_funcall(self, rb_intern("to_s"), 0);
  char *cptr = RSTRING_PTR(str);

  if (memcmp(cptr, "NaN", sizeof("NaN")) == 0 || memcmp(cptr, "Infinity", sizeof("Infinity")) == 0 || memcmp(cptr, "-Infinity", sizeof("-Infinity")) == 0) {
    rb_raise(cEncodeError, "'%s' is an invalid number", cptr);
  }

  if ( rb_hash_aref(state, rb_str_new2("processing_key")) == Qtrue ) {
    gen_string(rb_yajl_gen, str);
  } else {
    gen_number(rb_yajl_gen, str);
  }

  return Qnil;
}