Files
fullodds.club/lib/full_odds/cache.rb
T
2026-10-25 23:19:29 -06:00

29 lines
390 B
Ruby

# frozen_string_literal: true
module FO
class Cache
def initialize(init = {})
@c = init
end
def file!(path)
if @c[path].nil?
return @c[path] = File.read(path)
end
@c[path]
end
def get(k)
@c.fetch(k)
end
def set!(k, v)
@c[k] = v
end
def set(k, v)
self.class.new(@c.merge(k => v))
end
end
end