added 2.0.4 CFPropertyList

This commit is contained in:
Jeena Paradies 2010-06-18 14:52:31 +02:00
parent 4abce3b7ec
commit 14ae6ff27f
2 changed files with 27 additions and 3 deletions

View file

@ -55,7 +55,7 @@ module CFPropertyList
end
dirname = File.dirname(__FILE__)
require dirname + '/rbCFFormatError.rb'
require dirname + '/rbCFPlistError.rb'
require dirname + '/rbCFTypes.rb'
require dirname + '/rbXMLCFPropertyList.rb'
require dirname + '/rbBinaryCFPropertyList.rb'
@ -69,9 +69,12 @@ module CFPropertyList
# 'a' => ['b','c','d']
# }
# cftypes = CFPropertyList.guess(x)
#
# pass optional options hash. Only possible value actually:
# :convert_unknown_to_string => true
#
# cftypes = CFPropertyList.guess(x,:convert_unknown_to_string => true)
def guess(object, options = {})
return if object.nil?
if(object.is_a?(Fixnum) || object.is_a?(Integer)) then
return CFInteger.new(object)
elsif(object.is_a?(Float)) then
@ -103,6 +106,8 @@ module CFPropertyList
return CFDictionary.new(hsh)
elsif options[:convert_unknown_to_string]
return CFString.new(object.to_s)
else
raise CFTypeError.new("Unknown class #{object.class.to_s}! Try using :convert_unknown_to_string if you want to use unknown object types!")
end
end