Class: Prawn::ImageHandler

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

Extension API (collapse)

Constructor Details

- (ImageHandler) initialize

Returns a new instance of ImageHandler



17
18
19
# File 'lib/prawn/image_handler.rb', line 17

def initialize
  @handlers = []
end

Instance Method Details

- (Object) find(image_blob)



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

  fail Prawn::Errors::UnsupportedImageType,
       "image file is an unrecognised format"
end

- (Object) register(handler)



21
22
23
24
# File 'lib/prawn/image_handler.rb', line 21

def register(handler)
  @handlers.delete(handler)
  @handlers.push handler
end

- (Object) register!(handler)



26
27
28
29
# File 'lib/prawn/image_handler.rb', line 26

def register!(handler)
  @handlers.delete(handler)
  @handlers.unshift handler
end

- (Object) unregister(handler)



31
32
33
# File 'lib/prawn/image_handler.rb', line 31

def unregister(handler)
  @handlers.reject!{ |h| h == handler }
end