Class: ReportBuilder::ImageFilename
- 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
- #_image_magick ⇒ Object
- #create_file(directory) ⇒ Object
-
#initialize(filename, options = Hash.new) ⇒ ImageFilename
constructor
A new instance of ImageFilename.
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, =Hash.new) super() @filename=filename File.basename(@filename)=~/\.(.+)$/ @type=File.basename($1) end |
Instance Method Details
#_image_magick ⇒ Object
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 |