lib/care.rb in format_parser-0.1.6 vs lib/care.rb in format_parser-0.1.7

- old
+ new

@@ -23,10 +23,11 @@ def pos @pos end def read(n_bytes) + return '' if n_bytes == 0 # As hardcoded for all Ruby IO objects read = @cache.byteslice(@io, @pos, n_bytes) return nil unless read && !read.empty? @pos += read.bytesize read end @@ -60,10 +61,10 @@ # If the IO has been exhausted, `nil` will be returned # instead. Will use the cached pages where available, # or fetch pages where necessary def byteslice(io, at, n_bytes) if n_bytes < 1 - raise ArgumentError, "The number of bytes to fetch must be a positive Integer" + raise ArgumentError, "The number of bytes to fetch must be a positive Integer, but was #{n_bytes}" end if at < 0 raise ArgumentError, "Negative offsets are not supported (got #{at})" end