Class: Array

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

Instance Method Summary collapse

Instance Method Details

#ffi_yajl(rb_yajl_gen, state) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'ext/ffi_yajl/ext/encoder/encoder.c', line 239

def ffi_yajl(yajl_gen, state)
  if state[:processing_key]
    str = self.to_s
    if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
      FFI_Yajl::Encoder.raise_error_for_status(status, str)
    end
  else
    if ( status = FFI_Yajl.yajl_gen_array_open(yajl_gen) ) != 0
      FFI_Yajl::Encoder.raise_error_for_status(status, '[')
    end
    self.each do |value|
      value.ffi_yajl(yajl_gen, state)
    end
    if ( status = FFI_Yajl.yajl_gen_array_close(yajl_gen) ) != 0
      FFI_Yajl::Encoder.raise_error_for_status(status, ']')
    end
  end
end