module ZipContainer::Util

Utility methods useful throughout the rest of the ZipContainer library.

Public Instance Methods

entry_name(entry) → String click to toggle source

A lot of methods can take either a String or a Zip::Entry object to represent an item in a Zip file so this method normalizes these parameters.

In common with rubyzip this method also removes a trailing slash (/) from a name if it can.

# File lib/zip-container/util.rb, line 48
def entry_name(entry)
  name = entry.kind_of?(::Zip::Entry) ? : entry

  if name.respond_to?(:end_with?) && name.respond_to?(:chop!)
    name.chop! if name.end_with?("/")