class CF::Data

Wrapper for CFData

Public Class Methods

from_string(s) click to toggle source

Creates a CFData from a ruby string @param [String] s the string to use @return [CF::Data]

# File lib/corefoundation/data.rb, line 17
def self.from_string(s)
  new(CF.CFDataCreate(nil, s, s.bytesize))
end

Public Instance Methods

size() click to toggle source

The size in bytes of the CFData @return [Integer]

# File lib/corefoundation/data.rb, line 31
def size
  CF.CFDataGetLength(self)
end
to_ruby()
Alias for: to_s
to_s() click to toggle source

Creates a ruby string from the wrapped data. The encoding will always be ASCII_8BIT

@return [String]

# File lib/corefoundation/data.rb, line 24
def to_s
  ptr = CF.CFDataGetBytePtr(self)
  ptr.read_string(CF.CFDataGetLength(self)).force_encoding(Encoding::ASCII_8BIT)
end
Also aliased as: to_ruby