Class: Abrizer::Sprites
- Inherits:
-
Object
- Object
- Abrizer::Sprites
- Defined in:
- lib/abrizer/sprites.rb
Instance Method Summary collapse
- #create ⇒ Object
- #individual_image_glob ⇒ Object
- #individual_image_paths ⇒ Object
-
#initialize(filename, output_dir = nil) ⇒ Sprites
constructor
A new instance of Sprites.
- #optimize_images ⇒ Object
- #optimize_individual_images ⇒ Object
- #optimize_sprites ⇒ Object
- #sprite_paths ⇒ Object
- #sprites_glob ⇒ Object
Constructor Details
#initialize(filename, output_dir = nil) ⇒ Sprites
Returns a new instance of Sprites.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/abrizer/sprites.rb', line 4 def initialize(filename, output_dir=nil) @filename = filename @output_directory = File.join output_dir, 'sprites' # TODO: make video sprites options configurable @options = { seconds: 10, width: 160, columns: 4, group: 20, gif: false, keep_images: true } end |
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 |
# File 'lib/abrizer/sprites.rb', line 18 def create processor = VideoSprites::Processor.new(@filename, @output_directory, @options) processor.process FileUtils.chmod_R "go+r", @output_directory optimize_images end |
#individual_image_glob ⇒ Object
50 51 52 |
# File 'lib/abrizer/sprites.rb', line 50 def individual_image_glob File.join @output_directory, "images/*.jpg" end |
#individual_image_paths ⇒ Object
46 47 48 |
# File 'lib/abrizer/sprites.rb', line 46 def individual_image_paths Dir.glob(individual_image_glob) end |
#optimize_images ⇒ Object
25 26 27 28 |
# File 'lib/abrizer/sprites.rb', line 25 def optimize_images optimize_sprites optimize_individual_images end |
#optimize_individual_images ⇒ Object
42 43 44 |
# File 'lib/abrizer/sprites.rb', line 42 def optimize_individual_images `jpegoptim #{individual_image_paths.join(' ')}` end |
#optimize_sprites ⇒ Object
30 31 32 |
# File 'lib/abrizer/sprites.rb', line 30 def optimize_sprites `jpegoptim #{sprite_paths.join(' ')}` end |
#sprite_paths ⇒ Object
34 35 36 |
# File 'lib/abrizer/sprites.rb', line 34 def sprite_paths Dir.glob(sprites_glob) end |
#sprites_glob ⇒ Object
38 39 40 |
# File 'lib/abrizer/sprites.rb', line 38 def sprites_glob File.join @output_directory, "*.jpg" end |