Module: Omnizip::Entry

Overview

Mix-in that establishes the common contract every archive entry satisfies, regardless of format.

Each format-specific entry class (Zip::Entry, Tar::Entry, SevenZip::Models::FileEntry, Iso::DirectoryRecord, Ole::Dirent, Xar::Entry, Rpm::Entry, Msi::Entry, Cpio::Entry, Rar3::Entry, Rar5::Entry, Xz::Entry, Metadata::EntryMetadata) includes this module so callers can rely on a single narrow interface instead of duck-typing through respond_to?(:name) / :path / :filename cascades.

Including classes MUST override the four methods below. The defaults raise NotImplementedError to surface missing implementations at call time rather than at include time.

Instance Method Summary collapse

Instance Method Details

#entry_directory?Boolean

Returns true if the entry is a directory.

Returns:

  • (Boolean)

    true if the entry is a directory

Raises:

  • (NotImplementedError)


27
28
29
30
# File 'lib/omnizip/entry.rb', line 27

def entry_directory?
  raise NotImplementedError,
        "#{self.class} must implement #entry_directory?"
end

#entry_mtimeTime?

Returns modification time.

Returns:

  • (Time, nil)

    modification time

Raises:

  • (NotImplementedError)


39
40
41
42
# File 'lib/omnizip/entry.rb', line 39

def entry_mtime
  raise NotImplementedError,
        "#{self.class} must implement #entry_mtime"
end

#entry_nameString?

Returns in-archive path, or nil if the entry has no name (e.g. empty anti-entry).

Returns:

  • (String, nil)

    in-archive path, or nil if the entry has no name (e.g. empty anti-entry)

Raises:

  • (NotImplementedError)


21
22
23
24
# File 'lib/omnizip/entry.rb', line 21

def entry_name
  raise NotImplementedError,
        "#{self.class} must implement #entry_name"
end

#entry_sizeInteger?

Returns uncompressed size in bytes.

Returns:

  • (Integer, nil)

    uncompressed size in bytes

Raises:

  • (NotImplementedError)


33
34
35
36
# File 'lib/omnizip/entry.rb', line 33

def entry_size
  raise NotImplementedError,
        "#{self.class} must implement #entry_size"
end