Module: ZipContainer::Util

Defined in:
lib/zip-container/util.rb

Overview

Utility methods useful throughout the rest of the ZipContainer library.

Class Method Summary collapse

Class Method Details

.entry_name(entry) ⇒ Object

:call-seq:

entry_name(entry) -> String

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.



53
54
55
56
57
# File 'lib/zip-container/util.rb', line 53

def entry_name(entry)
  name = entry.is_a?(::Zip::Entry) ? entry.name : entry

  name.respond_to?(:chomp) ? name.chomp('/') : name
end