Class: Spritely::SpriteMap
- Inherits:
-
Object
- Object
- Spritely::SpriteMap
- Extended by:
- Forwardable
- Defined in:
- lib/spritely/sprite_map.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#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 20 |
# File 'lib/spritely/sprite_map.rb', line 14 def initialize(name, environment, ) @name = name @environment = environment @options = .dup @directory = @options.delete(:directory) || name @glob = [directory, "*.png"].join("/") end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
12 13 14 |
# File 'lib/spritely/sprite_map.rb', line 12 def directory @directory end |
#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
26 27 28 |
# File 'lib/spritely/sprite_map.rb', line 26 def cache_key @cache_key ||= Digest::MD5.hexdigest([, collection].join) end |
#collection ⇒ Object
30 31 32 |
# File 'lib/spritely/sprite_map.rb', line 30 def collection @collection ||= Collection.create(files, ) end |
#files ⇒ Object
38 39 40 |
# File 'lib/spritely/sprite_map.rb', line 38 def files environment.paths.flat_map { |path| Dir.glob(File.join(path, glob)) }.sort end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/spritely/sprite_map.rb', line 22 def inspect "#<Spritely::SpriteMap name=#{name} directory=#{directory} options=#{}>" end |
#save! ⇒ Object
34 35 36 |
# File 'lib/spritely/sprite_map.rb', line 34 def save! Generators::ChunkyPng.new(self).build! end |