Class: Prawn::ImageHandler
- Inherits:
-
Object
- Object
- Prawn::ImageHandler
- Defined in:
- lib/prawn/image_handler.rb
Extension API collapse
- #find(image_blob) ⇒ Object
-
#initialize ⇒ ImageHandler
constructor
A new instance of ImageHandler.
- #register(handler) ⇒ Object
- #register!(handler) ⇒ Object
- #unregister(handler) ⇒ Object
Constructor Details
#initialize ⇒ ImageHandler
Returns a new instance of ImageHandler.
17 18 19 |
# File 'lib/prawn/image_handler.rb', line 17 def initialize @handlers = [] end |
Instance Method Details
#find(image_blob) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/prawn/image_handler.rb', line 35 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) ⇒ Object
21 22 23 24 |
# File 'lib/prawn/image_handler.rb', line 21 def register(handler) @handlers.delete(handler) @handlers.push handler end |
#register!(handler) ⇒ Object
26 27 28 29 |
# File 'lib/prawn/image_handler.rb', line 26 def register!(handler) @handlers.delete(handler) @handlers.unshift handler end |
#unregister(handler) ⇒ Object
31 32 33 |
# File 'lib/prawn/image_handler.rb', line 31 def unregister(handler) @handlers.reject! { |h| h == handler } end |