class IO

Public Instance Methods

bookmark(rewind=false, &block) click to toggle source

saves the position and returns to it after the block is executed. Returns the block’s reply. if rewind, io.rewind is called before handing the io object to the block.

# File lib/io/bookmark.rb, line 6
def bookmark(rewind=false, &block)
  start = self.pos
  self.rewind if rewind
  reply = block.call(self) 
  self.pos = start
  reply
end