Class: Resync::Client::Zip::Bitstream
- Inherits:
-
Object
- Object
- Resync::Client::Zip::Bitstream
- Defined in:
- lib/resync/client/zip/bitstream.rb
Overview
A single entry in a ZIP package.
Instance Attribute Summary collapse
-
#metadata ⇒ Metadata
readonly
The metadata for this bitstream.
-
#path ⇒ String
readonly
The path to the entry within the ZIP file.
-
#resource ⇒ Resource
readonly
The resource describing this bitstream.
Instance Method Summary collapse
-
#content ⇒ Object
The content of the bitstream.
-
#get_input_stream ⇒ ::Zip::InputStream
The bitstream, as an
IO
-like object. -
#initialize(zipfile:, resource:) ⇒ Bitstream
constructor
Creates a new bitstream for the specified resource.
-
#mime_type ⇒ Object
The content type of the bitstream, as per #metadata.
-
#size ⇒ Object
The (uncompressed) size of the bitstream.
Constructor Details
#initialize(zipfile:, resource:) ⇒ Bitstream
Creates a new bitstream for the specified resource.
29 30 31 32 |
# File 'lib/resync/client/zip/bitstream.rb', line 29 def initialize(zipfile:, resource:) self.resource = resource @zip_entry = zipfile.find_entry(@path) end |
Instance Attribute Details
#metadata ⇒ Metadata
Returns the metadata for this bitstream.
20 21 22 |
# File 'lib/resync/client/zip/bitstream.rb', line 20 def @metadata end |
#path ⇒ String
Returns the path to the entry within the ZIP file.
14 15 16 |
# File 'lib/resync/client/zip/bitstream.rb', line 14 def path @path end |
#resource ⇒ Resource
Returns the resource describing this bitstream.
17 18 19 |
# File 'lib/resync/client/zip/bitstream.rb', line 17 def resource @resource end |
Instance Method Details
#content ⇒ Object
The content of the bitstream. The content will be read only once.
51 52 53 |
# File 'lib/resync/client/zip/bitstream.rb', line 51 def content @content ||= get_input_stream.read end |
#get_input_stream ⇒ ::Zip::InputStream
The bitstream, as an IO
-like object. Each call to this method will return a new stream.
45 46 47 |
# File 'lib/resync/client/zip/bitstream.rb', line 45 def get_input_stream # rubocop:disable Style/AccessorMethodName @zip_entry.get_input_stream end |
#mime_type ⇒ Object
The content type of the bitstream, as per #metadata.
56 57 58 |
# File 'lib/resync/client/zip/bitstream.rb', line 56 def mime_type @mime_type ||= .mime_type end |
#size ⇒ Object
The (uncompressed) size of the bitstream.
38 39 40 |
# File 'lib/resync/client/zip/bitstream.rb', line 38 def size @size ||= @zip_entry.size end |