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
- #collection ⇒ Object
- #filename ⇒ Object
- #generate! ⇒ Object
-
#initialize(glob, options = {}) ⇒ SpriteMap
constructor
A new instance of SpriteMap.
- #inspect ⇒ Object
- #name ⇒ Object
- #needs_generation? ⇒ Boolean
Constructor Details
#initialize(glob, options = {}) ⇒ SpriteMap
19 20 21 22 |
# File 'lib/spritely/sprite_map.rb', line 19 def initialize(glob, = {}) @glob = glob.value = Options.new() end |
Instance Attribute Details
#glob ⇒ Object (readonly)
Returns the value of attribute glob.
11 12 13 |
# File 'lib/spritely/sprite_map.rb', line 11 def glob @glob end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/spritely/sprite_map.rb', line 11 def end |
Class Method Details
.create(*args) ⇒ Object
13 14 15 16 17 |
# File 'lib/spritely/sprite_map.rb', line 13 def self.create(*args) new(*args).tap do |sprite_map| sprite_map.generate! if sprite_map.needs_generation? end end |
Instance Method Details
#collection ⇒ Object
28 29 30 |
# File 'lib/spritely/sprite_map.rb', line 28 def collection @collection ||= Collection.create(files, ) end |
#filename ⇒ Object
40 41 42 |
# File 'lib/spritely/sprite_map.rb', line 40 def filename Spritely.directory.join("#{name}.png") end |
#generate! ⇒ Object
32 33 34 |
# File 'lib/spritely/sprite_map.rb', line 32 def generate! Generators::ChunkyPng.create!(self) end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/spritely/sprite_map.rb', line 24 def inspect "#<Spritely::SpriteMap name=#{name} filename=#{filename}>" end |
#name ⇒ Object
36 37 38 |
# File 'lib/spritely/sprite_map.rb', line 36 def name glob.split('/')[0..-2].join('-') end |
#needs_generation? ⇒ Boolean
44 45 46 |
# File 'lib/spritely/sprite_map.rb', line 44 def needs_generation? !File.exist?(filename) || outdated? end |