Method: Montage::Sprite#initialize

Defined in:
lib/montage/sprite.rb

#initialize(name, sources, save_path, project, options = {}) ⇒ Sprite

Creates a new Sprite instance.

Parameters:

  • name (String)

    The name of the sprite. Will be used as the sprite filename (with an extension added).

  • sources (Array(String, Pathname))

    The name of each source image.

  • save_path (Pathname)

    The location at which the sprite should be saved.

  • project (Montage::Project)

    The project to which the sprite belongs.

  • options (Hash) (defaults to: {})

    Extra options where you wish to override project defaults.



21
22
23
24
25
26
27
28
29
# File 'lib/montage/sprite.rb', line 21

def initialize(name, sources, save_path, project, options = {})
  @name      = name
  @save_path = save_path

  @padding   = options.fetch(:padding, project.padding)
  @url       = options.fetch(:url, project.paths.url)

  @sources   = sources.map { |path| Source.new(path) }
end