Class: GLib::Bytes
Overview
Overrides for GBytes, GLib’s immutable array of bytes.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#get_data ⇒ Object
NOTE: Needed due to mis-identification of the element-type of the resulting sized array for the default binding.
-
#initialize(arr) ⇒ Bytes
constructor
A new instance of Bytes.
Constructor Details
#initialize(arr) ⇒ Bytes
Returns a new instance of Bytes.
37 38 39 40 |
# File 'lib/ffi-glib/bytes.rb', line 37 def initialize(arr) data = GirFFI::SizedArray.from :guint8, arr.size, arr store_pointer Lib.g_bytes_new data.to_ptr, data.size end |
Class Method Details
.from(obj) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ffi-glib/bytes.rb', line 26 def self.from(obj) case obj when self obj when FFI::Pointer wrap obj else new obj end end |
Instance Method Details
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/ffi-glib/bytes.rb', line 22 def each(&block) data.each(&block) end |
#get_data ⇒ Object
NOTE: Needed due to mis-identification of the element-type of the resulting sized array for the default binding.
15 16 17 18 19 20 |
# File 'lib/ffi-glib/bytes.rb', line 15 def get_data length_ptr = FFI::MemoryPointer.new :size_t data_ptr = Lib.g_bytes_get_data self, length_ptr length = length_ptr.get_size_t(0) GirFFI::SizedArray.wrap(:guint8, length, data_ptr) end |