class CFPropertyList::CFData

This class contains binary data values

Constants

DATA_BASE64

Base64 encoded data

DATA_RAW

Raw data

Public Class Methods

new(value=nil,format=DATA_BASE64) click to toggle source

set value to defined state, either base64 encoded or raw

# File lib/cfpropertylist/rbCFTypes.rb, line 234
def initialize(value=nil,format=DATA_BASE64)
  if(format == DATA_RAW)
    @raw_value = value
  else
    @value = value
  end
end

Public Instance Methods

decoded_value() click to toggle source

get base64 decoded value

# File lib/cfpropertylist/rbCFTypes.rb, line 248
def decoded_value
  @raw_value ||= Blob.new(Base64.decode64(@value))
end
encoded_value() click to toggle source

get base64 encoded value

# File lib/cfpropertylist/rbCFTypes.rb, line 243
def encoded_value
  @value ||= "\n#{Base64.encode64(@raw_value).gsub("\n", '').scan(/.{1,76}/).join("\n")}\n"
end
to_binary(bplist) click to toggle source

convert to binary

# File lib/cfpropertylist/rbCFTypes.rb, line 260
def to_binary(bplist)
  bplist.data_to_binary(decoded_value())
end
to_plain(plist) click to toggle source
# File lib/cfpropertylist/rbCFTypes.rb, line 264
def to_plain(plist)
  "<" + decoded_value.unpack("H*").join("") + ">"
end
to_xml(parser) click to toggle source

convert to XML

# File lib/cfpropertylist/rbCFTypes.rb, line 253
def to_xml(parser)
  n = parser.new_node('data')
  n = parser.append_node(n, parser.new_text(encoded_value()))
  n
end