Class: Yattho::Octicon::Cache
- Inherits:
-
Object
- Object
- Yattho::Octicon::Cache
- Defined in:
- app/lib/yattho/octicon/cache.rb
Overview
:nodoc:
Constant Summary collapse
- LOOKUP =
rubocop:disable Style/MutableConstant
{}
- PRELOADED_ICONS =
Preload the top 20 used icons.
[:alert, :check, :'chevron-down', :paste, :clock, :'dot-fill', :info, :'kebab-horizontal', :link, :lock, :mail, :pencil, :plus, :question, :repo, :search, :'shield-lock', :star, :trash, :x].freeze
Class Method Summary collapse
- .clear! ⇒ Object
- .get_key(symbol:, size:, width: nil, height: nil) ⇒ Object
-
.limit ⇒ Object
Cache size limit.
- .preload! ⇒ Object
- .read(key) ⇒ Object
- .set(key, value) ⇒ Object
Class Method Details
.clear! ⇒ Object
35 36 37 |
# File 'app/lib/yattho/octicon/cache.rb', line 35 def clear! LOOKUP.clear end |
.get_key(symbol:, size:, width: nil, height: nil) ⇒ Object
13 14 15 16 17 |
# File 'app/lib/yattho/octicon/cache.rb', line 13 def get_key(symbol:, size:, width: nil, height: nil) attrs = { symbol: symbol, size: size, width: width, height: height } attrs.compact! attrs.hash end |
.limit ⇒ Object
Cache size limit.
24 25 26 |
# File 'app/lib/yattho/octicon/cache.rb', line 24 def limit 500 end |
.preload! ⇒ Object
39 40 41 |
# File 'app/lib/yattho/octicon/cache.rb', line 39 def preload! PRELOADED_ICONS.each { |icon| Yattho::Beta::Octicon.new(icon: icon) } end |
.read(key) ⇒ Object
19 20 21 |
# File 'app/lib/yattho/octicon/cache.rb', line 19 def read(key) LOOKUP[key] end |