Class: ReportBuilder::ImageBlob
- Defined in:
- lib/reportbuilder/image.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
Returns the value of attribute blob.
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(blob, options = Hash.new) ⇒ ImageBlob
constructor
A new instance of ImageBlob.
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(blob, options = Hash.new) ⇒ ImageBlob
Returns a new instance of ImageBlob.
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/reportbuilder/image.rb', line 168 def initialize(blob, =Hash.new) super() @blob=blob if !@type if blob[0,40]=~/<svg/ @type='svg' else @type='jpg' end end end |
Instance Attribute Details
#blob ⇒ Object
Returns the value of attribute blob.
167 168 169 |
# File 'lib/reportbuilder/image.rb', line 167 def blob @blob end |
Instance Method Details
#_image_magick ⇒ Object
179 180 181 182 183 184 185 186 187 |
# File 'lib/reportbuilder/image.rb', line 179 def _image_magick that=self img=Magick::Image.from_blob(@blob) { if that.type=='svg' self.format='SVG' end } img.first end |
#create_file(directory) ⇒ Object
188 189 190 191 192 193 194 195 196 |
# File 'lib/reportbuilder/image.rb', line 188 def create_file(directory) FileUtils.mkdir_p directory+"/images" @filename=directory+"/images/"+@id+"."+@type @url="images/"+@id+"."+@type File.open(@filename,"w") do |fp| fp.write @blob end @filename end |