Method: Vpim::DirectoryInfo::Field#value
- Defined in:
- lib/vpim/field.rb
#value ⇒ Object
The decoded value.
The encoding specified by the #encoding, if any, is stripped.
Note: Both the RFC 2425 encoding param (“b”, meaning base-64) and the vCard 2.1 encoding params (“base64”, “quoted-printable”, “8bit”, and “7bit”) are supported.
FIXME:
-
should use the VALUE parameter
-
should also take a default value type, so it can be converted if VALUE parameter is not present.
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/vpim/field.rb', line 312 def value case encoding when nil, '8BIT', '7BIT' then @value # Hack - if the base64 lines started with 2 SPC chars, which is invalid, # there will be extra spaces in @value. Since no SPC chars show up in # b64 encodings, they can be safely stripped out before unpacking. when 'B', 'BASE64' then @value.gsub(' ', '').unpack('m*').first when 'QUOTED-PRINTABLE' then @value.unpack('M*').first else raise Vpim::InvalidEncodingError, "unrecognized encoding (#{encoding})" end end |