Class: DynamicSprites::Generator
- Inherits:
-
Object
- Object
- DynamicSprites::Generator
- Defined in:
- lib/dynamic-sprites/generator.rb
Overview
Generates sprites
Constant Summary collapse
- VALID_EXTENSIONS =
Array of file extensions used for creating sprites.
%w(.png .jpg .jpeg .gif .ico)
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#layout ⇒ Object
readonly
Returns the value of attribute layout.
Instance Method Summary collapse
-
#initialize(filename, path, layout) ⇒ Generator
constructor
Initializer.
-
#run! ⇒ Object
Main method for sprites generation.
Constructor Details
#initialize(filename, path, layout) ⇒ Generator
Initializer
filename - Pathname where generated file should be placed to. path - Pathname of directory containing source images. layout - sprite layout name as a String
19 20 21 22 23 |
# File 'lib/dynamic-sprites/generator.rb', line 19 def initialize(filename, path, layout) @filename = filename @layout = layout @files = Dir.glob(File.join(path, '*')).select { |e| VALID_EXTENSIONS.include?(File.extname(e)) } end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
9 10 11 |
# File 'lib/dynamic-sprites/generator.rb', line 9 def filename @filename end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
11 12 13 |
# File 'lib/dynamic-sprites/generator.rb', line 11 def files @files end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
10 11 12 |
# File 'lib/dynamic-sprites/generator.rb', line 10 def layout @layout end |
Instance Method Details
#run! ⇒ Object
Main method for sprites generation
27 28 29 |
# File 'lib/dynamic-sprites/generator.rb', line 27 def run! create(filename, load(files), layout) end |