Class: CFPropertyList::CFData
Overview
This class contains binary data values
Constant Summary collapse
- DATA_BASE64 =
Base64 encoded data
0
- DATA_RAW =
Raw data
1
Instance Attribute Summary
Attributes inherited from CFType
Instance Method Summary collapse
-
#decoded_value ⇒ Object
get base64 decoded value.
-
#encoded_value ⇒ Object
get base64 encoded value.
-
#initialize(value = nil, format = DATA_BASE64) ⇒ CFData
constructor
set value to defined state, either base64 encoded or raw.
-
#to_binary(bplist) ⇒ Object
convert to binary.
-
#to_xml(parser) ⇒ Object
convert to XML.
Constructor Details
Instance Method Details
#decoded_value ⇒ Object
get base64 decoded value
184 185 186 |
# File 'lib/rbCFTypes.rb', line 184 def decoded_value @raw_value ||= Blob.new(Base64.decode64(@value)) end |
#encoded_value ⇒ Object
get base64 encoded value
179 180 181 |
# File 'lib/rbCFTypes.rb', line 179 def encoded_value @value ||= "\n#{Base64.encode64(@raw_value).gsub("\n", '').scan(/.{1,76}/).join("\n")}\n" end |
#to_binary(bplist) ⇒ Object
convert to binary
196 197 198 |
# File 'lib/rbCFTypes.rb', line 196 def to_binary(bplist) bplist.data_to_binary(decoded_value()) end |
#to_xml(parser) ⇒ Object
convert to XML
189 190 191 192 193 |
# File 'lib/rbCFTypes.rb', line 189 def to_xml(parser) n = parser.new_node('data') n = parser.append_node(n, parser.new_text(encoded_value())) n end |