Module: LucideRails::IconProvider
- Defined in:
- lib/lucide-rails/icon_provider.rb
Class Method Summary collapse
- .icon(named) ⇒ Object
- .memory ⇒ Object
- .provide_from_filesystem(named) ⇒ Object
- .provide_from_memory(named) ⇒ Object
Class Method Details
.icon(named) ⇒ Object
7 8 9 |
# File 'lib/lucide-rails/icon_provider.rb', line 7 def icon(named) send("provide_from_#{LucideRails.provider}", named) end |
.memory ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/lucide-rails/icon_provider.rb', line 25 def memory return @memory if @memory file_path = LucideRails::GEM_ROOT.join("icons/stripped.bin.gz") data = ActiveSupport::Gzip.decompress(File.read(file_path)) @memory = data.split("\x00").to_h { |x| x.split(",", 2) } end |
.provide_from_filesystem(named) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/lucide-rails/icon_provider.rb', line 11 def provide_from_filesystem(named) file = LucideRails::GEM_ROOT.join("icons", "stripped", "#{named}.svg") raise ArgumentError, "Unknown icon #{named}" unless file.exist? File.read(file) end |
.provide_from_memory(named) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/lucide-rails/icon_provider.rb', line 18 def provide_from_memory(named) named = named.to_s raise ArgumentError, "Unknown icon #{named}" unless memory.key? named memory[named] end |