class Tilia::VObject::Property::Binary
BINARY property.
This object represents BINARY values.
Binary
values are most commonly used by the iCalendar ATTACH property, and the vCard PHOTO property.
This property will transparently encode and decode to base64.
Attributes
In case this is a multi-value property. This string will be used as a delimiter.
@return [String, nil]
Public Class Methods
Tilia::VObject::Property::new
# File lib/tilia/v_object/property/binary.rb, line 89 def initialize(*args) super(*args) @delimiter = nil end
Public Instance Methods
Returns the value, in the format it should be encoded for json.
This method must always return an array.
@return [array]
# File lib/tilia/v_object/property/binary.rb, line 73 def json_value [Base64.strict_encode64(value)] end
Sets the json value, as it would appear in a jCard or jCal object.
The value must always be an array.
@param [array] value
@return [void]
Tilia::VObject::Property#json_value=
# File lib/tilia/v_object/property/binary.rb, line 84 def json_value=(value) value = value.map { |v| Base64.decode64(v) } super(value) end
Returns a raw mime-dir representation of the value.
@return [String]
# File lib/tilia/v_object/property/binary.rb, line 54 def raw_mime_dir_value Base64.strict_encode64(@value) end
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
This has been 'unfolded', so only 1 line will be passed. Unescaping is not yet done, but parameters are not included.
@param [String] val
@return [void]
# File lib/tilia/v_object/property/binary.rb, line 47 def raw_mime_dir_value=(val) @value = Base64.decode64(val) end
Updates the current value.
This may be either a single, or multiple strings in an array.
@param [String|array] value
@return [void]
# File lib/tilia/v_object/property/binary.rb, line 27 def value=(value) if value.is_a?(Array) if value.size == 1 @value = value.first else fail ArgumentError, 'The argument must either be a string or an array with only one child' end else @value = value end end
Returns the type of value.
This corresponds to the VALUE= parameter. Every property also has a 'default' valueType.
@return [String]
# File lib/tilia/v_object/property/binary.rb, line 64 def value_type 'BINARY' end