Class: CF::Data
Overview
Wrapper for CFData
Class Method Summary collapse
-
.from_string(s) ⇒ CF::Data
Creates a CFData from a ruby string.
Instance Method Summary collapse
-
#size ⇒ Integer
The size in bytes of the CFData.
-
#to_s ⇒ String
(also: #to_ruby)
Creates a ruby string from the wrapped data.
Methods inherited from Base
check_cftype, #eql?, #equals?, #hash, #initialize, #inspect, #null?, #ptr=, #release, #release_on_gc, #retain, #to_cf, #to_ptr, typecast
Constructor Details
This class inherits a constructor from CF::Base
Class Method Details
Instance Method Details
#size ⇒ Integer
The size in bytes of the CFData
35 36 37 |
# File 'lib/corefoundation/data.rb', line 35 def size CF.CFDataGetLength(self) end |
#to_s ⇒ String Also known as: to_ruby
Creates a ruby string from the wrapped data. The encoding will always be ASCII_8BIT
24 25 26 27 28 29 30 31 |
# File 'lib/corefoundation/data.rb', line 24 def to_s ptr = CF.CFDataGetBytePtr(self) if CF::String::HAS_ENCODING ptr.read_string(CF.CFDataGetLength(self)).force_encoding(Encoding::ASCII_8BIT) else ptr.read_string(CF.CFDataGetLength(self)) end end |