Class: MTX::InputCache

Inherits:
Object
  • Object
show all
Defined in:
lib/minglr/mtx/input_cache.rb

Class Method Summary collapse

Class Method Details

.get(key) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/minglr/mtx/input_cache.rb', line 8

def get(key)
  if content = File.read(file_pathname(key))
    return nil if content.blank?
    content
  end
rescue
  nil
end

.put(key, content) ⇒ Object



4
5
6
# File 'lib/minglr/mtx/input_cache.rb', line 4

def put(key, content)
  File.open(file_pathname(key), File::CREAT | File::WRONLY | File::TRUNC) { |file| file.write content }
end