Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Psych::Emitter.new
Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS)
ext/psych/psych_emitter.c
View on GitHub ↗
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;
}
Create a new Psych::Emitter that writes to io.