module Rabbit::Parser::Ext::Image
Public Instance Methods
make_image(canvas, uri_str, prop={})
click to toggle source
# File lib/rabbit/parser/ext/image.rb, line 30 def make_image(canvas, uri_str, prop={}) path = Private.uri_string_to_image_filename(canvas, uri_str) begin Element::Image.new(path, prop) rescue Error canvas.logger.warn($!.message) nil end end
make_image_from_file(canvas, source) { |path| ... }
click to toggle source
# File lib/rabbit/parser/ext/image.rb, line 40 def make_image_from_file(canvas, source) src_file = Tempfile.new("rabbit-image-source") src_file.open src_file.print(source) src_file.close image_file = prop = nil begin image_file, prop = yield(src_file.path) rescue ImageLoadError canvas.logger.warn($!.message) end return nil if image_file.nil? image = make_image(canvas, %Q[file://#{image_file.path}], prop) return nil if image.nil? image["_src"] = image_file # for protecting from GC image end