Module: ZipContainer::ReservedNames
- Includes:
- Util
- Included in:
- Container, ManagedDirectory
- Defined in:
- lib/zip-container/entries/reserved.rb
Overview
This module provides support for reserved names.
Instance Method Summary collapse
-
#reserved_entry?(entry) ⇒ Boolean
:call-seq: reserved_entry?(entry) -> boolean.
-
#reserved_names ⇒ Object
:call-seq: reserved_names -> Array.
Methods included from Util
Instance Method Details
#reserved_entry?(entry) ⇒ Boolean
:call-seq:
reserved_entry?(entry) -> boolean
Is the given entry in the reserved list of names? A String or a Zip::Entry object can be passed in here.
71 72 73 74 |
# File 'lib/zip-container/entries/reserved.rb', line 71 def reserved_entry?(entry) name = entry_name(entry) reserved_names.map(&:downcase).include? name.downcase end |
#reserved_names ⇒ Object
:call-seq:
reserved_names -> Array
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
62 63 64 |
# File 'lib/zip-container/entries/reserved.rb', line 62 def reserved_names @reserved_names ||= [] end |