Sha256: e7c6ffd66e5bc2b97ec43838d35a82e17d65b7cd6bc5616a6fb7f6da20ed2eb6
Contents?: true
Size: 1.04 KB
Versions: 10
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Primer module Octicon # :nodoc: class Cache LOOKUP = {} # rubocop:disable Style/MutableConstant # Preload the top 20 used icons. PRELOADED_ICONS = [:alert, :check, :"chevron-down", :clippy, :clock, :"dot-fill", :info, :"kebab-horizontal", :link, :lock, :mail, :pencil, :plus, :question, :repo, :search, :"shield-lock", :star, :trash, :x].freeze class << self def get_key(symbol:, size:, width: nil, height: nil) [symbol, size, width, height].join("_") end def read(key) LOOKUP[key] end # Cache size limit. def limit 500 end def set(key, value) LOOKUP[key] = value # Remove first item when the cache is too large. LOOKUP.shift if LOOKUP.size > limit end def clear! LOOKUP.clear end def preload! PRELOADED_ICONS.each { |icon| Primer::OcticonComponent.new(icon: icon) } end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems