Sha256: 82846d5b71fb250d2f79cefabf99777b616201cd1b9b0fad1f75c04c0aa67e13

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

require "savagery/spriter/image"

module Savagery
  class Spriter
    def initialize path
      self.path = path
    end

    attr_accessor :path

    def sprite!
      File.write sprite_path, sprite
      sprite_path
    end

    private

    def sprite_path
      path + ".svg"
    end

    def sprite
      "<svg><defs>\n\n#{symbols.join("\n")}\n</defs></svg>\n"
    end

    def symbols
      Image.from_paths(image_paths).map(&:symbol)
    end

    def image_paths
      Dir.glob(path + "/*.svg").sort
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
savagery-0.1.0 lib/savagery/spriter.rb
savagery-0.0.1 lib/savagery/spriter.rb