Class: Prawn::ImageHandler
- Inherits:
-
Object
- Object
- Prawn::ImageHandler
- Defined in:
- lib/prawn/image_handler.rb
Overview
ImageHandler provides a way to register image processors with Prawn.
Extension API collapse
-
#find(image_blob) ⇒ Object
Find an image handler for an image.
-
#register(handler) ⇒ void
Register an image handler.
-
#register!(handler) ⇒ void
Register an image handler with the highest priority.
-
#unregister(handler) ⇒ void
Unregister an image handler.
Instance Method Details
#find(image_blob) ⇒ Object
Find an image handler for an image.
52 53 54 55 56 57 58 59 |
# File 'lib/prawn/image_handler.rb', line 52 def find(image_blob) handler = @handlers.find { |h| h.can_render?(image_blob) } return handler if handler raise Prawn::Errors::UnsupportedImageType, 'image file is an unrecognised format' end |
#register(handler) ⇒ void
This method returns an undefined value.
Register an image handler.
24 25 26 27 |
# File 'lib/prawn/image_handler.rb', line 24 def register(handler) @handlers.delete(handler) @handlers.push(handler) end |
#register!(handler) ⇒ void
This method returns an undefined value.
Register an image handler with the highest priority.
33 34 35 36 |
# File 'lib/prawn/image_handler.rb', line 33 def register!(handler) @handlers.delete(handler) @handlers.unshift(handler) end |
#unregister(handler) ⇒ void
This method returns an undefined value.
Unregister an image handler.
42 43 44 |
# File 'lib/prawn/image_handler.rb', line 42 def unregister(handler) @handlers.reject! { |h| h == handler } end |