class Resync::Client::Zip::Bitstream
A single entry in a ZIP package.
Attributes
metadata[R]
@return [Metadata] the metadata for this bitstream
path[R]
@return [String] the path to the entry within the ZIP file
resource[R]
@return [Resource] the resource describing this bitstream
Public Class Methods
new(zipfile:, resource:)
click to toggle source
Creates a new bitstream for the specified resource.
@param zipfile [::Zip::File] The zipfile to read the bitstream from. @param resource [Resource] The resource describing the bitstream.
# File lib/resync/client/zip/bitstream.rb, line 29 def initialize(zipfile:, resource:) self.resource = resource @zip_entry = zipfile.find_entry(@path) end
Public Instance Methods
content()
click to toggle source
The content of the bitstream. The content will be read only once.
# File lib/resync/client/zip/bitstream.rb, line 51 def content @content ||= get_input_stream.read end
get_input_stream()
click to toggle source
The bitstream, as an IO
-like object. Each call to this method will return a new stream. @return [::Zip::InputStream] the bitstream.
# 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()
click to toggle source
The content type of the bitstream, as per {#metadata}.
# File lib/resync/client/zip/bitstream.rb, line 56 def mime_type @mime_type ||= metadata.mime_type end
size()
click to toggle source
The (uncompressed) size of the bitstream.
# File lib/resync/client/zip/bitstream.rb, line 38 def size @size ||= @zip_entry.size end
Private Instance Methods
metadata=(value)
click to toggle source
# File lib/resync/client/zip/bitstream.rb, line 71 def metadata=(value) raise 'no metadata found' unless value self.path = value.path @metadata = value end
path=(value)
click to toggle source
# File lib/resync/client/zip/bitstream.rb, line 77 def path=(value) raise 'no path found in metadata' unless value @path = value.start_with?('/') ? value.slice(1..-1) : value end
resource=(value)
click to toggle source
Private methods
# File lib/resync/client/zip/bitstream.rb, line 65 def resource=(value) raise ArgumentError, 'nil is not a resource' unless value self.metadata = value.metadata @resource = value end