Class: Prawn::ImageHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/image_handler.rb

Extension API collapse

Constructor Details

#initializeImageHandler

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