Class: Unarchiver::ZipEntry
- Inherits:
-
Object
- Object
- Unarchiver::ZipEntry
- Defined in:
- lib/unarchiver.rb
Instance Method Summary collapse
-
#initialize(entry, valid_extensions: nil) ⇒ ZipEntry
constructor
A new instance of ZipEntry.
-
#to_file ⇒ Object
Create a temporary file and add it to the list of files.
- #valid? ⇒ Boolean
Constructor Details
#initialize(entry, valid_extensions: nil) ⇒ ZipEntry
Returns a new instance of ZipEntry.
47 48 49 50 |
# File 'lib/unarchiver.rb', line 47 def initialize(entry, valid_extensions: nil) @entry = entry @valid_extensions = valid_extensions end |
Instance Method Details
#to_file ⇒ Object
Create a temporary file and add it to the list of files. We need to ensure we keep the extension so that the parser can determine the correct file format; that’s what the second argument to Tempfile.new is for.
60 61 62 |
# File 'lib/unarchiver.rb', line 60 def to_file Unarchiver.temp_file(read, entry.name, extension) end |
#valid? ⇒ Boolean
52 53 54 |
# File 'lib/unarchiver.rb', line 52 def valid? entry.file? && visible? && valid_extension? end |