Sha256: 1fed2824a43ef56449ad2db86eaf7512aaf1905029835c4df698de77739e68dc
Contents?: true
Size: 561 Bytes
Versions: 1
Compression:
Stored size: 561 Bytes
Contents
module FilePool require 'digest/md5' class Pool def initialize(pool_path) @pool_path = pool_path Dir.mkdir @pool_path unless Dir.exist? @pool_path end def puts(row_data) md5 = Digest::MD5.hexdigest(row_data) file_path = File.join(@pool_path, md5) File.open(file_path, 'w+').write(row_data) unless File.exist? file_path return md5 end def delete(file_id) file_path = File.join(@pool_path, file_id) File.unlink file_path if File.exist? file_path end def exist?(file_id) File.exist? File.join(@pool_path, file_id) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_fs-0.0.1 | lib/simple_fs/file_pool.rb |