Class: CFPropertyList228::CFData
- Defined in:
- lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb
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
#initialize(value = nil, format = DATA_BASE64) ⇒ CFData
set value to defined state, either base64 encoded or raw
177 178 179 180 181 182 183 |
# File 'lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb', line 177 def initialize(value=nil,format=DATA_BASE64) if(format == DATA_RAW) @raw_value = value else @value = value end end |
Instance Method Details
#decoded_value ⇒ Object
get base64 decoded value
191 192 193 |
# File 'lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb', line 191 def decoded_value @raw_value ||= Blob.new(Base64.decode64(@value)) end |
#encoded_value ⇒ Object
get base64 encoded value
186 187 188 |
# File 'lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb', line 186 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
203 204 205 |
# File 'lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb', line 203 def to_binary(bplist) bplist.data_to_binary(decoded_value()) end |
#to_xml(parser) ⇒ Object
convert to XML
196 197 198 199 200 |
# File 'lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb', line 196 def to_xml(parser) n = parser.new_node('data') n = parser.append_node(n, parser.new_text(encoded_value())) n end |