Class: Prawn::ImageHandler

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

Overview

ImageHandler provides a way to register image processors with Prawn.

Extension API collapse

Instance Method Details

#find(image_blob) ⇒ Object

Find an image handler for an image.

Parameters:

  • image_blob (String)

Returns:

  • (Object)

Raises:

Source Code
lib/prawn/image_handler.rb, line 52
52
def find(image_blob)
53
  handler = @handlers.find { |h| h.can_render?(image_blob) }
54
55
  return handler if handler
56
57
  raise Prawn::Errors::UnsupportedImageType,
58
    'image file is an unrecognised format'
59
end

#register(handler) ⇒ void

This method returns an undefined value.

Register an image handler.

Parameters:

  • handler (Object)
Source Code
lib/prawn/image_handler.rb, line 24
24
def register(handler)
25
  @handlers.delete(handler)
26
  @handlers.push(handler)
27
end

#register!(handler) ⇒ void

This method returns an undefined value.

Register an image handler with the highest priority.

Parameters:

  • handler (Object)
Source Code
lib/prawn/image_handler.rb, line 33
33
def register!(handler)
34
  @handlers.delete(handler)
35
  @handlers.unshift(handler)
36
end

#unregister(handler) ⇒ void

This method returns an undefined value.

Unregister an image handler.

Parameters:

  • handler (Object)
Source Code
lib/prawn/image_handler.rb, line 42
42
def unregister(handler)
43
  @handlers.reject! { |h| h == handler }
44
end