Class: Spritely::SpriteMap
- Inherits:
-
Object
- Object
- Spritely::SpriteMap
- Extended by:
- Forwardable
- Defined in:
- lib/spritely/sprite_map.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#glob ⇒ Object
readonly
Returns the value of attribute glob.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #cache_key ⇒ Object
- #collection ⇒ Object
- #files ⇒ Object
-
#initialize(name, environment, options) ⇒ SpriteMap
constructor
A new instance of SpriteMap.
- #inspect ⇒ Object
- #save! ⇒ Object
Constructor Details
#initialize(name, environment, options) ⇒ SpriteMap
Returns a new instance of SpriteMap.
14 15 16 17 18 19 |
# File 'lib/spritely/sprite_map.rb', line 14 def initialize(name, environment, ) @name = name @glob = [name, "*.png"].join("/") @environment = environment @options = end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
12 13 14 |
# File 'lib/spritely/sprite_map.rb', line 12 def environment @environment end |
#glob ⇒ Object (readonly)
Returns the value of attribute glob.
12 13 14 |
# File 'lib/spritely/sprite_map.rb', line 12 def glob @glob end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/spritely/sprite_map.rb', line 12 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/spritely/sprite_map.rb', line 12 def @options end |
Instance Method Details
#cache_key ⇒ Object
25 26 27 |
# File 'lib/spritely/sprite_map.rb', line 25 def cache_key @cache_key ||= Digest::MD5.hexdigest([, collection].join) end |
#collection ⇒ Object
29 30 31 |
# File 'lib/spritely/sprite_map.rb', line 29 def collection @collection ||= Collection.create(files, ) end |
#files ⇒ Object
37 38 39 |
# File 'lib/spritely/sprite_map.rb', line 37 def files environment.paths.flat_map { |path| Dir.glob(File.join(path, glob)) }.sort end |
#inspect ⇒ Object
21 22 23 |
# File 'lib/spritely/sprite_map.rb', line 21 def inspect "#<Spritely::SpriteMap name=#{name} options=#{}>" end |
#save! ⇒ Object
33 34 35 |
# File 'lib/spritely/sprite_map.rb', line 33 def save! Generators::ChunkyPng.new(self).build! end |