class SimplyInlineSvg::Storage

Attributes

data[RW]

Public Class Methods

find(name) click to toggle source
# File lib/simply_inline_svg/storage.rb, line 26
def find(name)
  self.data[name]
end
find!(name) click to toggle source
# File lib/simply_inline_svg/storage.rb, line 21
def find!(name)
  raise SvgNotFound if self.data[name].nil?
  self.data[name]
end
register_directory(directory) click to toggle source
# File lib/simply_inline_svg/storage.rb, line 7
def register_directory(directory)
  fpaths = Dir["#{directory}/**/*.svg"]
  while fpaths.length > 0
    fpath = fpaths.shift
    register_svg(File.basename(fpath), fpath)
  end
  self.data
end
register_svg(fname, fpath) click to toggle source
# File lib/simply_inline_svg/storage.rb, line 16
def register_svg(fname, fpath)
  svg = Svg.new(File.read(fpath))
  self.data.merge!({ fname => svg })
end