Class: Spritely::SpriteMap
- Inherits:
-
Sass::Script::Literal
- Object
- Sass::Script::Literal
- Spritely::SpriteMap
- Extended by:
- Forwardable
- Defined in:
- lib/spritely/sprite_map.rb
Instance Attribute Summary collapse
-
#glob ⇒ Object
readonly
Returns the value of attribute glob.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #cache_key ⇒ Object
- #collection ⇒ Object
- #filename ⇒ Object
- #files ⇒ Object
- #generate! ⇒ Object
-
#initialize(glob, options = {}) ⇒ SpriteMap
constructor
A new instance of SpriteMap.
- #inspect ⇒ Object
- #name ⇒ Object
- #needs_generation? ⇒ Boolean
Constructor Details
Instance Attribute Details
#glob ⇒ Object (readonly)
Returns the value of attribute glob.
13 14 15 |
# File 'lib/spritely/sprite_map.rb', line 13 def glob @glob end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/spritely/sprite_map.rb', line 13 def @options end |
Class Method Details
.create(*args) ⇒ Object
15 16 17 18 19 |
# File 'lib/spritely/sprite_map.rb', line 15 def self.create(*args) new(*args).tap do |sprite_map| sprite_map.generate! if sprite_map.needs_generation? end end |
Instance Method Details
#cache_key ⇒ Object
26 27 28 |
# File 'lib/spritely/sprite_map.rb', line 26 def cache_key @cache_key ||= Cache.generate(, collection) end |
#collection ⇒ Object
34 35 36 |
# File 'lib/spritely/sprite_map.rb', line 34 def collection @collection ||= Collection.create(files, ) end |
#filename ⇒ Object
46 47 48 |
# File 'lib/spritely/sprite_map.rb', line 46 def filename Spritely.directory.join("#{name}.png") end |
#files ⇒ Object
54 55 56 |
# File 'lib/spritely/sprite_map.rb', line 54 def files Spritely.environment.paths.flat_map { |path| Dir.glob(File.join(path, glob)) }.sort end |
#generate! ⇒ Object
38 39 40 |
# File 'lib/spritely/sprite_map.rb', line 38 def generate! Generators::ChunkyPng.create!(self) end |
#inspect ⇒ Object
30 31 32 |
# File 'lib/spritely/sprite_map.rb', line 30 def inspect "#<Spritely::SpriteMap name=#{name} options=#{}>" end |
#name ⇒ Object
42 43 44 |
# File 'lib/spritely/sprite_map.rb', line 42 def name glob.split('/')[0..-2].join('-') end |