File: strv.rb

package info (click to toggle)
ruby-gir-ffi 0.16.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 924 kB
  • sloc: ruby: 6,849; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 656 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module GLib
  # Represents a null-terminated array of strings. GLib uses this construction,
  # but does not provide any actual functions for this class.
  #
  # The implementation is mainly inherited from GObjectIntrospection::Strv.
  class Strv < GObjectIntrospection::Strv
    def ==(other)
      to_a == other.to_a
    end

    def self.from(obj)
      case obj
      when nil
        nil
      when FFI::Pointer
        wrap obj
      when self
        obj
      else
        from_enumerable obj
      end
    end

    def self.from_enumerable(enum)
      wrap GirFFI::InPointer.from_array :utf8, enum
    end
  end
end