Class: ReportBuilder::ImageFilename

Inherits:
Image
  • Object
show all
Defined in:
lib/reportbuilder/image.rb

Instance Attribute Summary

Attributes inherited from Image

#alt, #chars, #filename, #font_cols, #font_rows, #height, #id, #name, #svg_raster, #type, #url, #width

Instance Method Summary collapse

Methods inherited from Image

#generate_raster_from_svg, #generate_tag_html, #image_magick, #report_building_html, #report_building_pdf, #report_building_rtf, #report_building_text

Constructor Details

#initialize(filename, options = Hash.new) ⇒ ImageFilename

Returns a new instance of ImageFilename.



201
202
203
204
205
206
# File 'lib/reportbuilder/image.rb', line 201

def initialize(filename, options=Hash.new)
  super(options)
  @filename=filename
  File.basename(@filename)=~/\.(.+)$/
  @type=File.basename($1)
end

Instance Method Details

#_image_magickObject



207
208
209
# File 'lib/reportbuilder/image.rb', line 207

def _image_magick
  Magick::Image.read(@filename).first
end

#create_file(directory) ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
# File 'lib/reportbuilder/image.rb', line 210

def create_file(directory)
  basedir=directory+"/images"
  out=basedir+"/"+File.basename(@filename)
  @url="images/#{File.basename(@filename)}"
  if(File.exists? @filename)
    FileUtils.mkdir_p basedir
    if (!File.exists? out or (File.mtime(out) < File.mtime(@filename)))
      FileUtils.cp @filename, out
    end
  end
end