Class: Bignum

Inherits:
Object show all
Defined in:
lib/ffi_yajl/ffi/encoder.rb

Instance Method Summary collapse

Instance Method Details

#ffi_yajl(yajl_gen, state) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'ext/ffi_yajl/ext/encoder/encoder.c', line 158

def ffi_yajl(yajl_gen, state)
  str = self.to_s
  if str == "NaN" || str == "Infinity" || str == "-Infinity"
    raise ::FFI_Yajl::EncodeError.new("'#{str}' is an invalid number")
  end
  if state[:processing_key]
    if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
      FFI_Yajl::Encoder.raise_error_for_status(status)
    end
  else
    if ( status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize) ) != 0
      FFI_Yajl::Encoder.raise_error_for_status(status)
    end
  end
end