Class: Rack::Archive::Zip::Extract::ExtractedFile
- Inherits:
-
Object
- Object
- Rack::Archive::Zip::Extract::ExtractedFile
- Defined in:
- lib/rack/archive/zip/extract.rb
Constant Summary collapse
- BUFFER_SIZE =
8192
Instance Attribute Summary collapse
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
-
#initialize(archive, path, buffer_size = BUFFER_SIZE) ⇒ ExtractedFile
constructor
A new instance of ExtractedFile.
Constructor Details
permalink #initialize(archive, path, buffer_size = BUFFER_SIZE) ⇒ ExtractedFile
Returns a new instance of ExtractedFile.
134 135 136 137 138 139 140 141 142 |
# File 'lib/rack/archive/zip/extract.rb', line 134 def initialize(archive, path, buffer_size=BUFFER_SIZE) raise ArgumentError, 'archive already closed' unless archive.open? @archive = archive @file = @archive.fopen(path) @mtime = @file.mtime @size = @file.size @etag = Digest::MD5.hexdigest(@file.name) + @mtime.to_i.to_s(16) + @size.to_s(16) @buffer_size = buffer_size end |
Instance Attribute Details
permalink #etag ⇒ Object (readonly)
Returns the value of attribute etag.
128 129 130 |
# File 'lib/rack/archive/zip/extract.rb', line 128 def etag @etag end |
permalink #mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
128 129 130 |
# File 'lib/rack/archive/zip/extract.rb', line 128 def mtime @mtime end |
permalink #size ⇒ Object (readonly)
Returns the value of attribute size.
128 129 130 |
# File 'lib/rack/archive/zip/extract.rb', line 128 def size @size end |
Instance Method Details
permalink #close ⇒ Object
[View source]
150 151 152 153 |
# File 'lib/rack/archive/zip/extract.rb', line 150 def close @file.close @archive.close end |
permalink #each ⇒ Object
[View source]
144 145 146 147 148 |
# File 'lib/rack/archive/zip/extract.rb', line 144 def each while chunk = @file.read(@buffer_size) yield chunk end end |