Sha256: 7a5b5f096639a45d86a382488fa4850437912f89fb507db682a48d8c391bd33a
Contents?: true
Size: 915 Bytes
Versions: 2
Compression:
Stored size: 915 Bytes
Contents
# encoding: utf-8 # ImageHandler provides a way to register image processors with Prawn # # Contributed by Evan Sharp in November 2013. # # This is free software. Please see the LICENSE and COPYING files for details. module Prawn # @group Extension API def self.image_handler @image_handler ||= ImageHandler.new end class ImageHandler def initialize @handlers = [] end def register(handler) @handlers.delete(handler) @handlers.push handler end def register!(handler) @handlers.delete(handler) @handlers.unshift handler end def unregister(handler) @handlers.reject!{ |h| h == handler } end def find(image_blob) handler = @handlers.find{ |h| h.can_render? image_blob } return handler if handler fail Prawn::Errors::UnsupportedImageType, "image file is an unrecognised format" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prawn-2.1.0 | lib/prawn/image_handler.rb |
prawn-2.0.2 | lib/prawn/image_handler.rb |