Class: Resync::Bitstream
- Inherits:
-
Object
- Object
- Resync::Bitstream
- Defined in:
- lib/resync/client/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.
-
#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.
-
#stream ⇒ Object
The bitstream, as an +IO+-like object.
Constructor Details
#initialize(zipfile:, resource:) ⇒ Bitstream
Creates a new bitstream for the specified resource.
25 26 27 28 |
# File 'lib/resync/client/bitstream.rb', line 25 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.
16 17 18 |
# File 'lib/resync/client/bitstream.rb', line 16 def @metadata end |
#path ⇒ String
Returns the path to the entry within the ZIP file.
10 11 12 |
# File 'lib/resync/client/bitstream.rb', line 10 def path @path end |
#resource ⇒ Resource
Returns the resource describing this bitstream.
13 14 15 |
# File 'lib/resync/client/bitstream.rb', line 13 def resource @resource end |
Instance Method Details
#content ⇒ Object
The content of the bitstream. The content will be read only once.
46 47 48 |
# File 'lib/resync/client/bitstream.rb', line 46 def content @content ||= stream.read end |
#mime_type ⇒ Object
The content type of the bitstream, as per #metadata.
51 52 53 |
# File 'lib/resync/client/bitstream.rb', line 51 def mime_type @mime_type ||= .mime_type end |
#size ⇒ Object
The (uncompressed) size of the bitstream.
34 35 36 |
# File 'lib/resync/client/bitstream.rb', line 34 def size @size ||= @zip_entry.size end |
#stream ⇒ Object
The bitstream, as an +IO+-like object. Subsequent calls will return the same stream.
40 41 42 |
# File 'lib/resync/client/bitstream.rb', line 40 def stream @stream ||= @zip_entry.get_input_stream end |