class Fontist::Utils::CacheIndex
Public Class Methods
Source
# File lib/fontist/utils/cache.rb, line 20 def self.from_file(path) return new unless File.exist?(path) content = File.read(path) return new if content.strip.empty? || content.strip == "---" from_yaml(content) || {} end
Public Instance Methods
Source
# File lib/fontist/utils/cache.rb, line 34 def [](key) Array(items).find { |i| i.url == key }&.name end
Source
# File lib/fontist/utils/cache.rb, line 38 def []=(key, value) item = Array(items).find { |i| i.url == key } if item item.name = value else items << CacheIndexItem.new(url: key, name: value) end end
Source
# File lib/fontist/utils/cache.rb, line 47 def delete(key) item = Array(items).find { |i| i.url == key } items.delete(item) if item end
Source
# File lib/fontist/utils/cache.rb, line 30 def to_file(path) File.write(path, to_yaml) end