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
return CFReal.new(object)
elsif(object.is_a?(TrueClass) || object.is_a?(FalseClass)) then
return CFBoolean.new(object)
elsif(object.is_a?(String)) then
return CFString.new(object)
elsif(object.is_a?(Time) || object.is_a?(DateTime)) then
return CFDate.new(object)
elsif(object.is_a?(IO)) then
return CFData.new(object.read, CFData::DATA_RAW)
elsif(object.is_a?(Array)) then
ary = Array.new
object.each do
|o|
ary.push CFPropertyList.guess(o, options)
end
return CFArray.new(ary)
elsif(object.is_a?(Hash)) then
hsh = Hash.new
object.each_pair do
|k,v|
k = k.to_s if k.is_a?(Symbol)
hsh[k] = CFPropertyList.guess(v, options)
end
return CFDictionary.new(hsh)
elsif options[:convert_unknown_to_string]
return CFString.new(object.to_s)
end
end