Sha256: 9b343d53331e29d3b8b85a7d3d3a9f2681897540e11509e69a676460c5b5d75f

Contents?: true

Size: 515 Bytes

Versions: 9

Compression:

Stored size: 515 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
      Lib.g_byte_array_append(to_ptr, bytes, len)
      self
    end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gir_ffi-0.17.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.16.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.16.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.9 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.8 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.7 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.6 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.5 lib/ffi-glib/byte_array.rb
gir_ffi-0.15.4 lib/ffi-glib/byte_array.rb