Class: Archive::BaseArchive Abstract
- Inherits:
-
Object
- Object
- Archive::BaseArchive
- Defined in:
- lib/ffi_libarchive/archive.rb
Overview
This class is abstract.
Instance Method Summary collapse
- #close ⇒ Object
- #errno ⇒ Integer
- #error_string ⇒ String
-
#initialize(alloc, free) ⇒ BaseArchive
constructor
A new instance of BaseArchive.
Constructor Details
#initialize(alloc, free) ⇒ BaseArchive
Returns a new instance of BaseArchive.
150 151 152 153 154 155 156 157 158 |
# File 'lib/ffi_libarchive/archive.rb', line 150 def initialize(alloc, free) raise ArgumentError, 'Invalid methods' unless alloc.respond_to?(:call) && free.respond_to?(:call) @archive = alloc.call raise Error, 'No archive open' unless @archive @archive_free = [free] ObjectSpace.define_finalizer(self, method(:close).to_proc) end |
Instance Method Details
#close ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/ffi_libarchive/archive.rb', line 160 def close # TODO: do we need synchronization here? @archive_free[0].call(@archive) if @archive && @archive_free[0].respond_to?(:call) # TODO: Error check? ensure @archive = nil @archive_free[0] = nil end |
#errno ⇒ Integer
178 179 180 |
# File 'lib/ffi_libarchive/archive.rb', line 178 def errno C.archive_errno(archive) end |
#error_string ⇒ String
173 174 175 |
# File 'lib/ffi_libarchive/archive.rb', line 173 def error_string C.archive_error_string(archive) end |