Class: Prawn::ImageHandler

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

Instance Method Summary collapse

Constructor Details

#initializeImageHandler

Returns a new instance of ImageHandler.



7
8
9
# File 'lib/prawn/image_handler.rb', line 7

def initialize
  @handlers = []
end

Instance Method Details

#find(image_blob) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/prawn/image_handler.rb', line 25

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



11
12
13
14
# File 'lib/prawn/image_handler.rb', line 11

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

#register!(handler) ⇒ Object



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

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

#unregister(handler) ⇒ Object



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

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