Class: RubyArchive::Handler
- Defined in:
- lib/ruby_archive/handler.rb,
lib/ruby_archive.rb
Overview
RubyArchive::Handler
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
reader for @name, which should be set in
initialize
.
Class Method Summary collapse
-
.handles?(location) ⇒ Boolean
Should return true if the class can handle the given location as an archive.
-
.normalize_path(location) ⇒ Object
Should return a normalized version of the location specified.
Instance Method Summary collapse
-
#close ⇒ Object
Close the handler.
-
#dir ⇒ Object
Should return a
Dir
-like object for the archive (optional) Should returnnil
if not supported. -
#file ⇒ Object
Should return a
File
-like object for the archive. -
#initialize(location) ⇒ Handler
constructor
Initialize a handler object for the location given.
- #inspect ⇒ Object
Constructor Details
#initialize(location) ⇒ Handler
Initialize a handler object for the location given. The default implementation raises a NotImplementedError
.
Your implementation needs to set @name to identify the archive
24 25 26 |
# File 'lib/ruby_archive/handler.rb', line 24 def initialize location raise NotImplementedError, "Cannot initialize a handler of class #{self.class}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
reader for @name, which should be set in initialize
49 50 51 |
# File 'lib/ruby_archive/handler.rb', line 49 def name @name end |
Class Method Details
.handles?(location) ⇒ Boolean
Should return true if the class can handle the given location as an archive. Returns false otherwise. The default implementation always returns false, this must be overridden in your subclasses.
This method must NOT raise an exception.
9 10 11 |
# File 'lib/ruby_archive/handler.rb', line 9 def self.handles? location false end |
Instance Method Details
#close ⇒ Object
Close the handler. This will be executed when RubyArchive::close_all_archives
is executed, or at_exit
Should always return nil
32 33 34 |
# File 'lib/ruby_archive/handler.rb', line 32 def close nil end |
#dir ⇒ Object
Should return a Dir
-like object for the archive (optional) Should return nil
if not supported.
44 45 46 |
# File 'lib/ruby_archive/handler.rb', line 44 def dir nil end |
#file ⇒ Object
Should return a File
-like object for the archive. The default implementation raises a NotImplentedError
, must be overridden.
38 39 40 |
# File 'lib/ruby_archive/handler.rb', line 38 def file raise NotImplementedError, "Cannot retrieve a file object for class #{self.class}" end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/ruby_archive/handler.rb', line 51 def inspect "<#{self.class}:#{self.name}>" end |