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.
36 37 38 39 |
# File 'lib/ffi-glib/bytes.rb', line 36 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(it) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ffi-glib/bytes.rb', line 25 def self.from(it) case it when self it when FFI::Pointer wrap it else new it end end |
Instance Method Details
#each(&block) ⇒ Object
21 22 23 |
# File 'lib/ffi-glib/bytes.rb', line 21 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.
14 15 16 17 18 19 |
# File 'lib/ffi-glib/bytes.rb', line 14 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 |