Class: Wankel::SaxEncoder
- Inherits:
-
Object
- Object
- Wankel::SaxEncoder
- Defined in:
- lib/wankel/ex_sax_parser.rb,
ext/wankel/wankel_sax_encoder.c
Instance Method Summary collapse
- #array_close ⇒ Object
- #array_open ⇒ Object
- #bool ⇒ Object
- #boolean(b) ⇒ Object
- #complete ⇒ Object
-
#initialize(*args) ⇒ Object
constructor
call-seq: new().
- #map_close ⇒ Object
- #map_open ⇒ Object
- #null ⇒ Object
- #number(number) ⇒ Object
- #string(string) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
call-seq: new()
:beautify generate indented (beautiful) output. Default ‘false`.
:indent_string Set an indent string which is used when yajl_gen_beautify
is enabled. Maybe something like \\t or some number of
spaces. The default is four spaces ' '.
:validate_utf8 Normally the generator does not validate that strings you
pass to it are valid UTF8. Enabling this option will cause
it to do so.
:escape_solidus the forward solidus (slash or ‘/’ in human) is not required
to be escaped in json text. By default, YAJL will not escape
it in the iterest of saving bytes. Setting this flag will
cause YAJL to always escape '/' in generated JSON strings.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'ext/wankel/wankel_sax_encoder.c', line 50 static VALUE wankelSaxEncoder_initialize(int argc, VALUE * argv, VALUE self) { VALUE defaults = rb_const_get(c_wankel, intern_DEFAULTS); VALUE io, ; wankel_encoder * p; yajl_alloc_funcs alloc_funcs; rb_scan_args(argc, argv, "11", &io, &); if( == Qnil) { rb_iv_set(self, "@options", rb_funcall(defaults, intern_clone, 0) ); } else { Check_Type(, T_HASH); rb_iv_set(self, "@options", rb_funcall(defaults, intern_merge, 1, ) ); } = rb_iv_get(self, "@options"); if (!rb_respond_to(io, intern_io_write)) { rb_raise(e_encodeError, "output must be a an IO"); } Data_Get_Struct(self, wankel_encoder, p); p->output = io; alloc_funcs.malloc = yajl_helper_malloc; alloc_funcs.realloc = yajl_helper_realloc; alloc_funcs.free = yajl_helper_free; p->g = yajl_gen_alloc(&alloc_funcs); yajl_gen_configure(p->g, ); p->write_buffer_size = FIX2INT(rb_hash_aref(, ID2SYM(rb_intern("write_buffer_size")))); return self; } |
Instance Method Details
#array_close ⇒ Object
191 192 |
# File 'ext/wankel/wankel_sax_encoder.c', line 191 def array_close end |
#array_open ⇒ Object
178 179 |
# File 'ext/wankel/wankel_sax_encoder.c', line 178 def array_open end |
#bool ⇒ Object
57 58 |
# File 'lib/wankel/ex_sax_parser.rb', line 57 def bool end |
#boolean(b) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'ext/wankel/wankel_sax_encoder.c', line 139 static VALUE wankelSaxEncoder_boolean(VALUE self, VALUE b) { wankel_encoder * p; yajl_gen_status status; Data_Get_Struct(self, wankel_encoder, p); status = yajl_gen_bool(p->g, RTEST(b)); yajl_helper_check_gen_status(status); wankelSaxEncoder_flush(p); return Qnil; } |
#complete ⇒ Object
204 205 |
# File 'ext/wankel/wankel_sax_encoder.c', line 204 def complete end |
#map_close ⇒ Object
165 166 |
# File 'ext/wankel/wankel_sax_encoder.c', line 165 def map_close end |
#map_open ⇒ Object
152 153 |
# File 'ext/wankel/wankel_sax_encoder.c', line 152 def map_open end |
#null ⇒ Object
126 127 |
# File 'ext/wankel/wankel_sax_encoder.c', line 126 def null end |
#number(number) ⇒ Object
83 84 |
# File 'ext/wankel/wankel_sax_encoder.c', line 83 def number end |
#string(string) ⇒ Object
106 107 |
# File 'ext/wankel/wankel_sax_encoder.c', line 106 def string end |