lib/chunky_png/datastream.rb
# Verifies that the current stream is a PNG datastream by checking its signature.
#
# This method reads the PNG signature from the stream, setting the current position
# of the stream directly after the signature, where the IHDR chunk should begin.
#
# @param [IO] io The stream to read the PNG signature from.
# @raise [RuntimeError] An exception is raised if the PNG signature is not found at
#    the beginning of the stream.
Verifies that the current stream is a PNG datastream by checking its signature.
This method reads the PNG signature from the stream, setting the current position
of the stream directly after the signature, where the IHDR chunk should begin.
Verifies that the current stream is a PNG datastream by checking its signature . This method reads the PNG signature from the stream setting the current position of the stream directly after the signature where the IHDR chunk should begin .
def verify_signature!(io)
        signature = io.read(ChunkyPNG::Datastream::SIGNATURE.length)
        unless signature == ChunkyPNG::Datastream::SIGNATURE
          raise ChunkyPNG::SignatureMismatch, "PNG signature not found, found #{signature.inspect} instead of #{ChunkyPNG::Datastream::SIGNATURE.inspect}!"
        end
      end
def verify_signature! ( io ) signature = io . read ( ChunkyPNG :: Datastream :: SIGNATURE . length ) unless signature == ChunkyPNG :: Datastream :: SIGNATURE raise ChunkyPNG :: SignatureMismatch , "PNG signature not found, found #{signature.inspect} instead of #{ChunkyPNG::Datastream::SIGNATURE.inspect}!" end end
Verifies that the current stream is a PNG datastream by checking its signature.
Verifies that the current stream is a PNG datastream by checking its signature .
[RuntimeError] An exception is raised if the PNG signature is not found at the beginning of the stream.
[ RuntimeError ] An exception is raised if the PNG signature is not found at the beginning of the stream .
io
<not_specific>
<not_specific>
io The stream to read the PNG signature from.
io The stream to read the PNG signature from .