Class: Tilia::VObject::Property::Binary
- Inherits:
-
Tilia::VObject::Property
- Object
- Node
- Tilia::VObject::Property
- Tilia::VObject::Property::Binary
- Defined in:
- lib/tilia/v_object/property/binary.rb
Overview
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.
Constant Summary
Constants inherited from Node
Node::PROFILE_CALDAV, Node::PROFILE_CARDDAV, Node::REPAIR
Instance Attribute Summary collapse
-
#delimiter ⇒ String?
In case this is a multi-value property.
Attributes inherited from Tilia::VObject::Property
#group, #name, #parameters, #value
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(*args) ⇒ Binary
constructor
A new instance of Binary.
-
#json_value ⇒ array
Returns the value, in the format it should be encoded for json.
-
#json_value=(value) ⇒ void
Sets the json value, as it would appear in a jCard or jCal object.
-
#raw_mime_dir_value ⇒ String
Returns a raw mime-dir representation of the value.
-
#raw_mime_dir_value=(val) ⇒ void
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
-
#value=(value) ⇒ void
Updates the current value.
-
#value_type ⇒ String
Returns the type of value.
Methods inherited from Tilia::VObject::Property
#==, #[], #[]=, #add, #delete, #destroy, #initialize_copy, #json_serialize, #key?, #parts, #parts=, #serialize, #to_s, #validate, #xml_serialize, #xml_value=
Methods inherited from Node
#==, #[], #[]=, #delete, #destroy, #each, #json_serialize, #key?, #serialize, #size, #validate, #xml_serialize
Constructor Details
#initialize(*args) ⇒ Binary
Returns a new instance of Binary.
89 90 91 92 |
# File 'lib/tilia/v_object/property/binary.rb', line 89 def initialize(*args) super(*args) @delimiter = nil end |
Instance Attribute Details
#delimiter ⇒ String?
In case this is a multi-value property. This string will be used as a delimiter.
18 19 20 |
# File 'lib/tilia/v_object/property/binary.rb', line 18 def delimiter @delimiter end |
Instance Method Details
#json_value ⇒ array
Returns the value, in the format it should be encoded for json.
This method must always return an array.
73 74 75 |
# File 'lib/tilia/v_object/property/binary.rb', line 73 def json_value [Base64.strict_encode64(value)] end |
#json_value=(value) ⇒ void
This method returns an undefined value.
Sets the json value, as it would appear in a jCard or jCal object.
The value must always be an array.
84 85 86 87 |
# File 'lib/tilia/v_object/property/binary.rb', line 84 def json_value=(value) value = value.map { |v| Base64.decode64(v) } super(value) end |
#raw_mime_dir_value ⇒ String
Returns a raw mime-dir representation of the value.
54 55 56 |
# File 'lib/tilia/v_object/property/binary.rb', line 54 def raw_mime_dir_value Base64.strict_encode64(@value) end |
#raw_mime_dir_value=(val) ⇒ void
This method returns an undefined value.
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.
47 48 49 |
# File 'lib/tilia/v_object/property/binary.rb', line 47 def raw_mime_dir_value=(val) @value = Base64.decode64(val) end |
#value=(value) ⇒ void
This method returns an undefined value.
Updates the current value.
This may be either a single, or multiple strings in an array.
27 28 29 30 31 32 33 34 35 36 37 |
# 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 |
#value_type ⇒ String
Returns the type of value.
This corresponds to the VALUE= parameter. Every property also has a ‘default’ valueType.
64 65 66 |
# File 'lib/tilia/v_object/property/binary.rb', line 64 def value_type 'BINARY' end |