module ZipContainer::ReservedNames
This module provides support for reserved names.
Public Instance Methods
Source
# File lib/zip-container/entries/reserved.rb 71 def reserved_entry?(entry) 72 name = entry_name(entry) 73 reserved_names.map(&:downcase).include? name.downcase 74 end
Is the given entry in the reserved list of names? A String or a Zip::Entry object can be passed in here.
Source
# File lib/zip-container/entries/reserved.rb 62 def reserved_names 63 @reserved_names ||= [] 64 end
Return a list of reserved file and directory names for this ZipContainer
file.
Reserved files and directories must be accessed directly by methods within Container
(or subclasses of Container
). This is because they are fundamental to the format and might need to exhibit certain properties (such as no compression) that must be preserved. The “mimetype” file is an example of such a reserved entry.
To add a reserved name to a subclass of Container
simply add it to the list in the constructor (you must call the super constructor first!):
class MyContainer < ZipContainer::Container def initialize(filename) super(filename) register_reserved_name("my_reserved_name") end end
Protected Instance Methods
Source
# File lib/zip-container/entries/reserved.rb 82 def register_reserved_name(name) 83 @reserved_names ||= [] 84 @reserved_names << name unless @reserved_names.include? name 85 end
Add a reserved name to the list.