Class: GameIcons::DB

Inherits:
Object
  • Object
show all
Defined in:
lib/game_icons/db.rb

Constant Summary collapse

@@icons =

Class-level hash of icon names to their absolute path in this gem

Hash.new

Class Method Summary collapse

Class Method Details

.filesObject



25
26
27
28
# File 'lib/game_icons/db.rb', line 25

def files
  init
  @@icons
end

.initObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/game_icons/db.rb', line 7

def init
  return unless @@icons.empty?
  icons_dir = '../../resources/icons/ffffff/000000/1x1'
  resources = File.expand_path(icons_dir, File.dirname(__FILE__))
  Dir.glob("#{resources}/**/*.svg").each do |svg|
    name = File.basename(svg,'.svg').downcase #chop off .svg
    @@icons[name] = svg
    author  = svg.sub(resources,'')[%r{/(?<author>\w+)/},"author"]
    full_name = "#{author}/#{name}" # e.g. andymeneely/police-badge
    @@icons[full_name] = svg
  end
end

.namesObject



20
21
22
23
# File 'lib/game_icons/db.rb', line 20

def names
  init
  @@icons.keys
end