Object
# File lib/rbase/memo_file.rb, line 27 def read(index) @file.pos = index*BLOCK_SIZE + HEADER_SIZE result = '' loop do data = @file.read(BLOCK_SIZE) terminator_pos = data.index(BLOCK_TERMINATOR) if terminator_pos break result + data[0, terminator_pos] end result += data end end
# File lib/rbase/memo_file.rb, line 41 def write(value) @file.pos = @next_block*BLOCK_SIZE + HEADER_SIZE value += BLOCK_TERMINATOR blocks_num = (value.length+511)/512 @file.write [value].pack("a#{512*blocks_num}") position = @next_block @next_block += blocks_num update_header position end
Generated with the Darkfish Rdoc Generator 2.