Sha256: bbd8ece478f97ed06f8a077500007985c0759ee3ad1de3b805936a26b02bfa8b

Contents?: true

Size: 480 Bytes

Versions: 3

Compression:

Stored size: 480 Bytes

Contents

module Savagery
  class Spriter
    class Image < Struct.new(:path)
      def self.from_paths paths
        paths.map { |path| Image.new(path) }
      end

      def symbol
        %(<symbol id="#{name}">#{image}</symbol>\n)
      end

      private
      
      def name
        File.basename(path, ".svg")
      end

      def image
        data[/<svg\b[^>]*>(.+)<\/svg>/m, 1].gsub(/[\r\n]+/, "\n")
      end

      def data
        File.read(path)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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