Sha256: f78091f3ba4e33ca0f396a2292d2a583aa4044067221aca4806b1760840a7060

Contents?: true

Size: 520 Bytes

Versions: 4

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

GLib.load_class :ByteArray

module GLib
  # Overrides for GByteArray, GLib's automatically growing array of bytes.
  class ByteArray
    def to_string
      data.read_string len
    end

    def append(data)
      bytes = GirFFI::InPointer.from_utf8 data
      len = data.bytesize
      self.class.wrap Lib.g_byte_array_append(to_ptr, bytes, len)
    end

    def self.from(data)
      case data
      when self
        data
      else
        new.append(data)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.15.3 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.2 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.0 lib/ffi-glib/byte_array.rb