# File lib/ole/storage/base.rb, line 758 def open mode='r' raise Errno::EISDIR unless file? io = RangesIOMigrateable.new self, mode # TODO work on the mode string stuff a bit more. # maybe let the io object know about the mode, so it can refuse # to work for read/write appropriately. maybe redefine all unusable # methods using singleton class to throw errors. # for now, i just want to implement truncation on use of 'w'. later, # i need to do 'a' etc. case mode when 'r', 'r+' # as i don't enforce reading/writing, nothing changes here. kind of # need to enforce tt if i want modify times to work better. @modify_time = Time.now if mode == 'r+' when 'w' @modify_time = Time.now # io.truncate 0 #else # raise NotImplementedError, "unsupported mode - #{mode.inspect}" end if block_given? begin yield io ensure; io.close end else io end end