Method: Psych::Emitter#initialize
- Defined in:
- ext/psych/psych_emitter.c
#Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS) ⇒ Object
Create a new Psych::Emitter that writes to io.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'ext/psych/psych_emitter.c', line 74
static VALUE initialize(int argc, VALUE *argv, VALUE self)
{
yaml_emitter_t * emitter;
VALUE io, options;
VALUE line_width;
VALUE indent;
VALUE canonical;
TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
line_width = rb_funcall(options, id_line_width, 0);
indent = rb_funcall(options, id_indentation, 0);
canonical = rb_funcall(options, id_canonical, 0);
yaml_emitter_set_width(emitter, NUM2INT(line_width));
yaml_emitter_set_indent(emitter, NUM2INT(indent));
yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
}
rb_ivar_set(self, id_io, io);
yaml_emitter_set_output(emitter, writer, (void *)self);
return self;
}
|