IRubyObject io2 = null;
if(args.length == 2 && args[1] != null && !args[1].isNil()) {
io = args[1];
}
YAMLConfig cfg = YAML.config().version("1.0");
IOOutputStream iox = null;
if(null == io) {
io2 = self.getRuntime().fastGetClass("StringIO").callMethod(context, "new");
iox = new IOOutputStream(io2);
} else {
iox = new IOOutputStream(io);
}
Serializer ser = new JRubySerializer(new EmitterImpl(iox,cfg),new ResolverImpl(),cfg);
try {
ser.open();
Representer r = new JRubyRepresenter(ser, cfg);