@@ -140,13 +140,18 @@ public IRubyObject start_document(ThreadContext context, IRubyObject _version, I
140140 TypeConverter .checkType (context , _version , arrayClass );
141141
142142 RubyArray versionAry = _version .convertToArray ();
143+ Optional <SpecVersion > specVersion ;
143144 if (versionAry .size () == 2 ) {
144145 int versionInt0 = versionAry .eltInternal (0 ).convertToInteger ().getIntValue ();
145146 int versionInt1 = versionAry .eltInternal (1 ).convertToInteger ().getIntValue ();
146147
147- if (versionInt0 != 1 || versionInt1 != 2 ) {
148- // throw runtime.newArgumentError("invalid YAML version: " + versionAry);
148+ if (versionInt0 != 1 ) {
149+ throw runtime .newArgumentError ("invalid YAML version: " + versionAry );
149150 }
151+
152+ specVersion = Optional .of (new SpecVersion (versionInt0 , versionInt1 ));
153+ } else {
154+ specVersion = Optional .empty ();
150155 }
151156
152157 Map <String , String > tagsMap = new HashMap <>();
@@ -171,7 +176,7 @@ public IRubyObject start_document(ThreadContext context, IRubyObject _version, I
171176 }
172177 }
173178
174- DocumentStartEvent event = new DocumentStartEvent (!implicitBool , Optional . empty () , tagsMap , NULL_MARK , NULL_MARK );
179+ DocumentStartEvent event = new DocumentStartEvent (!implicitBool , specVersion , tagsMap , NULL_MARK , NULL_MARK );
175180 emit (context , event );
176181 return this ;
177182 }
0 commit comments