class ZipContainer::ManagedEntry
ManagedEntry
is the superclass of ManagedDirectory
and ManagedFile
. It should not be used directly but may be subclassed if necessary.
Attributes
The name of the ManagedEntry
. For the full path name of this entry use full_name.
Public Class Methods
Source
# File lib/zip-container/managed_entry.rb, line 54 def initialize(name, required, hidden) @parent = nil @name = name @required = required @hidden = hidden end
Create a new ManagedEntry
with the supplied name. The entry should also be marked as required or not and whether it is hidden for normal operations.
Public Instance Methods
Source
# File lib/zip-container/managed_entry.rb, line 99 def exists? container.entries.each do |entry| test = entry.ftype == :directory ? "#{full_name}/" : full_name return true if entry.name == test end false end
Does this ManagedEntry
exist in the Container
?
Source
# File lib/zip-container/managed_entry.rb, line 65 def full_name if @parent.is_a?(ZipContainer::Container) @name else "#{@parent.full_name}/#{@name}" end end
The fully qualified name of this ManagedEntry
.
Source
# File lib/zip-container/managed_entry.rb, line 78 def required? @required end
Is this ManagedEntry
required to be present according to the specification of its Container
?
Source
# File lib/zip-container/managed_entry.rb, line 116 def verify if @required && !exists? ["Entry '#{full_name}' is required but missing."] else [] end end
Verify this ManagedEntry
returning a list of reasons why it fails if it does so. The empty list is returned if verification passes.
Subclasses should override this method if they require more complex verification to be done.
Source
# File lib/zip-container/managed_entry.rb, line 139 def verify! messages = verify raise MalformedContainerError, messages unless messages.empty? end
Verify this ManagedEntry
raising a MalformedContainerError
if it fails.
Source
# File lib/zip-container/managed_entry.rb, line 130 def verify? verify.empty? end
Verify this ManagedEntry
by checking that it exists if it is required according to its Container
specification and validating its contents if necessary.
Protected Instance Methods
Source
# File lib/zip-container/managed_entry.rb, line 150 def container @parent.is_a?(ZipContainer::Container) ? @parent : @parent.container end
Return the Container
that this ManagedEntry
resides in.