Module: Digest::Instance
- Defined in:
- lib/gorge/digest/instance.rb
Instance Method Summary collapse
-
#io(io_like) ⇒ self
Updates the Digest using the entire contents of the given IO-like, and returns the Digest.
Instance Method Details
#io(io_like) ⇒ self
Updates the Digest using the entire contents of the given IO-like, and returns the Digest. Before reading, saves the current position of the IO-like, and seeks to the beginning. After reading, seeks back to the saved position.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gorge/digest/instance.rb', line 12 def io(io_like) pos = io_like.pos # save position io_like.seek(0) buffer = +"" while io_like.read(16384, buffer) self.update(buffer) end io_like.seek(pos) # restore position self end |