class Savagery::Spriter

Attributes

path[RW]

Public Class Methods

new(path) click to toggle source
# File lib/savagery/spriter.rb, line 5
def initialize path
  self.path = path
end

Public Instance Methods

sprite!() click to toggle source
# File lib/savagery/spriter.rb, line 11
def sprite!
  File.write sprite_path, sprite
end

Private Instance Methods

image_paths() click to toggle source
# File lib/savagery/spriter.rb, line 29
def image_paths
  Dir.glob(path + "/*.svg").sort
end
sprite() click to toggle source
# File lib/savagery/spriter.rb, line 21
def sprite
  %(<svg data-savagery-path="#{sprite_path.split("/assets/svgs/").last}" style="display: none"><defs>\n\n#{symbols.join("\n")}\n</defs></svg>\n)
end
sprite_path() click to toggle source
# File lib/savagery/spriter.rb, line 17
def sprite_path
  path + ".svg"
end
symbols() click to toggle source
# File lib/savagery/spriter.rb, line 25
def symbols
  Image.from_paths(image_paths).map(&:symbol)
end