class Rembrandt::Stores::File
Attributes
output_directory[R]
Public Class Methods
new(directory = nil)
click to toggle source
# File lib/rembrandt/stores/file.rb, line 11 def initialize(directory = nil) self.output_directory = directory || Config.file_store_directory create_directory end
Public Instance Methods
create_directory()
click to toggle source
# File lib/rembrandt/stores/file.rb, line 21 def create_directory FileUtils.mkdir_p output_directory end
filename_for(key)
click to toggle source
# File lib/rembrandt/stores/file.rb, line 38 def filename_for(key) output_directory + prefix + key end
flush()
click to toggle source
# File lib/rembrandt/stores/file.rb, line 46 def flush `rm -rf #{output_directory}/*` if Dir.exist?(output_directory) end
output_directory=(name)
click to toggle source
# File lib/rembrandt/stores/file.rb, line 16 def output_directory=(name) name += '/' unless name.end_with?('/') @output_directory = name end
prefix()
click to toggle source
# File lib/rembrandt/stores/file.rb, line 42 def prefix 'rembrandt_' end
read(key)
click to toggle source
# File lib/rembrandt/stores/file.rb, line 31 def read(key) filename = filename_for(key) if ::File.exist?(filename) ::File.read(filename_for(key)) end end
write(key, data)
click to toggle source
# File lib/rembrandt/stores/file.rb, line 25 def write(key, data) ::File.open( filename_for(key), "w" ) do |f| f.write(data) end end