def add_photo
x = Struct.new(:image, :link, :type).new
yield x
if x[:image] && x[:link]
raise ::Vcard::InvalidEncodingError, "Image is not allowed to be both inline and a link."
end
value = x[:image] || x[:link]
if !value
raise ::Vcard::InvalidEncodingError, "A image link or inline data must be provided."
end
params = {}
params["TYPE"] = x[:type] if( x[:type] && x[:type].length > 0 )
if x[:link]
params["VALUE"] = "URI"
else
params["ENCODING"] = :b64
if !x[:type]
raise ::Vcard::InvalidEncodingError, "Inline image data must have it's type set."
end
end
@card << ::Vcard::DirectoryInfo::Field.create( "PHOTO", value, params )
self
end