lib/chunky_png/datastream.rb in chunky_png-1.3.12 vs lib/chunky_png/datastream.rb in chunky_png-1.3.13
- old
+ new
@@ -1,5 +1,7 @@
+# frozen-string-literal: true
+
module ChunkyPNG
# The Datastream class represents a PNG formatted datastream. It supports
# both reading from and writing to strings, streams and files.
#
# A PNG datastream begins with the PNG signature, and then contains multiple
@@ -7,11 +9,11 @@
# (IEND) chunk.
#
# @see ChunkyPNG::Chunk
class Datastream
# The signature that each PNG file or stream should begin with.
- SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack("C8").force_encoding(Encoding::BINARY).freeze
+ SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10].pack("C8").force_encoding(::Encoding::BINARY).freeze
# The header chunk of this datastream.
# @return [ChunkyPNG::Chunk::Header]
attr_accessor :header_chunk
@@ -70,11 +72,11 @@
# Reads a PNG datastream from an input stream
# @param [IO] io The stream to read from.
# @return [ChunkyPNG::Datastream] The loaded datastream instance.
def from_io(io)
- io.set_encoding(Encoding::BINARY)
+ io.set_encoding(::Encoding::BINARY)
verify_signature!(io)
ds = new
while ds.end_chunk.nil?
chunk = ChunkyPNG::Chunk.read(io)
@@ -153,15 +155,9 @@
end
##################################################################################
# WRITING DATASTREAMS
##################################################################################
-
- # Returns an empty stream using binary encoding that can be used as stream to encode to.
- # @return [String] An empty, binary string.
- def self.empty_bytearray
- ChunkyPNG::EMPTY_BYTEARRAY.dup
- end
# Writes the datastream to the given output stream.
# @param [IO] io The output stream to write to.
def write(io)
io << SIGNATURE