Module: ZipContainer::Util
- Included in:
- ManagedEntries, ManagedEntry, ReservedNames
- Defined in:
- lib/zip-container/util.rb
Overview
Utility methods useful throughout the rest of the ZipContainer library.
Instance Method Summary collapse
-
#entry_name(entry) ⇒ Object
:call-seq: entry_name(entry) -> String.
Instance 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.
48 49 50 51 52 53 54 55 56 |
# File 'lib/zip-container/util.rb', line 48 def entry_name(entry) name = entry.is_a?(::Zip::Entry) ? entry.name : entry if name.respond_to?(:end_with?) && name.respond_to?(:chop!) name.chop! if name.end_with?('/') end name end |