Class: Omnizip::Buffer::SevenZipBridge::ReadProxy::Entry
- Inherits:
-
Object
- Object
- Omnizip::Buffer::SevenZipBridge::ReadProxy::Entry
- Defined in:
- lib/omnizip/buffer/seven_zip_bridge.rb
Overview
Entry wrapper matching MemoryArchive::Entry's surface
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #directory? ⇒ Boolean
-
#initialize(entry, reader, tmp) ⇒ Entry
constructor
A new instance of Entry.
-
#read(_size = nil) ⇒ String
Extract and return this entry's content.
- #time ⇒ Time?
Constructor Details
#initialize(entry, reader, tmp) ⇒ Entry
Returns a new instance of Entry.
122 123 124 125 126 127 128 |
# File 'lib/omnizip/buffer/seven_zip_bridge.rb', line 122 def initialize(entry, reader, tmp) @entry = entry @reader = reader @tmp = tmp @name = entry.is_dir ? "#{entry.name}/" : entry.name @size = entry.size end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
117 118 119 |
# File 'lib/omnizip/buffer/seven_zip_bridge.rb', line 117 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
117 118 119 |
# File 'lib/omnizip/buffer/seven_zip_bridge.rb', line 117 def size @size end |
Instance Method Details
#directory? ⇒ Boolean
131 132 133 |
# File 'lib/omnizip/buffer/seven_zip_bridge.rb', line 131 def directory? @entry.is_dir end |
#read(_size = nil) ⇒ String
Extract and return this entry's content
143 144 145 146 147 148 149 |
# File 'lib/omnizip/buffer/seven_zip_bridge.rb', line 143 def read(_size = nil) return "" if directory? || @entry.has_stream == false dest = File.join(@tmp, "entry", @entry.name) @reader.extract_entry(@entry.name, dest) File.binread(dest) end |
#time ⇒ Time?
136 137 138 |
# File 'lib/omnizip/buffer/seven_zip_bridge.rb', line 136 def time @entry.mtime end |