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, #type, #url, #width
Instance Method Summary collapse
- #create_file(directory) ⇒ Object
- #image_magick ⇒ Object
-
#initialize(blob, options = Hash.new) ⇒ ImageBlob
constructor
A new instance of ImageBlob.
Methods inherited from Image
#generate_raster_from_svg, #generate_tag_html, #report_building_html, #report_building_rtf, #report_building_text
Constructor Details
#initialize(blob, options = Hash.new) ⇒ ImageBlob
Returns a new instance of ImageBlob.
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/reportbuilder/image.rb', line 141 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.
140 141 142 |
# File 'lib/reportbuilder/image.rb', line 140 def blob @blob end |
Instance Method Details
#create_file(directory) ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/reportbuilder/image.rb', line 155 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 |
#image_magick ⇒ Object
152 153 154 |
# File 'lib/reportbuilder/image.rb', line 152 def image_magick Magick::Image.from_blob(@blob) end |