class WithTimedCache::YAMLCache
Public Class Methods
file_extension()
click to toggle source
# File lib/with_timed_cache/yaml_cache.rb, line 24 def self.file_extension "yml" end
new(key, opts = {})
click to toggle source
Calls superclass method
WithTimedCache::Cache::new
# File lib/with_timed_cache/yaml_cache.rb, line 9 def initialize(key, opts = {}) super filename = "#{key}_cache.yml" @location = opts[:location] || "tmp/#{filename}" @location = File.join(@location, "#{filename}") if File.directory?(@location) end
Public Instance Methods
read()
click to toggle source
# File lib/with_timed_cache/yaml_cache.rb, line 16 def read YAML.load @location end
write(data)
click to toggle source
# File lib/with_timed_cache/yaml_cache.rb, line 20 def write(data) File.open(@location, 'w') { |f| f.write data.to_yaml } end