Class: Gluttonberg::Library::QuickMagick::ImageList
- Inherits:
-
Object
- Object
- Gluttonberg::Library::QuickMagick::ImageList
- Defined in:
- lib/gluttonberg/library/quick_magick/image_list.rb
Instance Method Summary collapse
- #<<(more_images) ⇒ Object
-
#initialize(*filenames) ⇒ ImageList
constructor
A new instance of ImageList.
-
#save(output_filename) ⇒ Object
(also: #write)
Saves all images in the list to the output filename.
-
#to_ary ⇒ Object
(also: #to_a)
Returns an array of images for the images stored.
Constructor Details
#initialize(*filenames) ⇒ ImageList
Returns a new instance of ImageList.
7 8 9 10 11 |
# File 'lib/gluttonberg/library/quick_magick/image_list.rb', line 7 def initialize(*filenames) @images = filenames.inject([]) do |image_list, filename| image_list + QuickMagick::Image.read(filename) end end |
Instance Method Details
#<<(more_images) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gluttonberg/library/quick_magick/image_list.rb', line 51 def <<(more_images) case more_images when QuickMagick::Image then @images << more_images # Another image list when QuickMagick::ImageList then self << more_images.to_a when Array then @images += more_images else raise QuickMagick::QuickMagickError, "Invalid argument type" end self end |
#save(output_filename) ⇒ Object Also known as: write
Saves all images in the list to the output filename
34 35 36 37 38 39 40 |
# File 'lib/gluttonberg/library/quick_magick/image_list.rb', line 34 def save(output_filename) command_line = "" @images.each do |image| command_line << image.command_line end `convert #{command_line} "#{output_filename}"` end |
#to_ary ⇒ Object Also known as: to_a
Returns an array of images for the images stored
45 46 47 |
# File 'lib/gluttonberg/library/quick_magick/image_list.rb', line 45 def to_ary @images end |