From bd810795c589a81e8939b53ad921f823e7133ee9 Mon Sep 17 00:00:00 2001 From: why Date: Tue, 13 May 2003 06:34:18 +0000 Subject: * lib/yaml/rubytypes.rb: object and struct loading * lib/yaml.rb: YAML::detect_implicit will discover typing for a Ruby string * ext/syck/: Fixed portable comments, misuse of NULL and methods without return VALUEs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/yaml.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/yaml.rb') diff --git a/lib/yaml.rb b/lib/yaml.rb index 1b2a4ea81f..b5852b2257 100644 --- a/lib/yaml.rb +++ b/lib/yaml.rb @@ -104,18 +104,20 @@ module YAML @@loader.add_private_type( type_re, &transfer_proc ) end + # + # Detect typing of a string + # + def YAML.detect_implicit( val ) + @@loader.detect_implicit( val ) + end + # # Method to extract colon-seperated type and class, returning # the type and the constant of the class # def YAML.read_type_class( type, obj_class ) - type =~ /^([^:]+):(.+)/i - if $2 - type = $1 - $2.split( "::" ).each { |c| - obj_class = obj_class.const_get( c ) - } - end + scheme, domain, type, tclass = type.split( ':', 4 ) + tclass.split( "::" ).each { |c| obj_class = obj_class.const_get( c ) } if tclass return [ type, obj_class ] end -- cgit v1.2.3