Class: ReportBuilder::ImageBlob

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

Instance Attribute Summary collapse

Attributes inherited from Image

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

Instance Method Summary collapse

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, options=Hash.new)
  super(options)
  @blob=blob      
  if !@type
    if blob[0,40]=~/<svg/
      @type='svg'
    else
      @type='jpg'
    end
  end
end

Instance Attribute Details

#blobObject

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_magickObject



152
153
154
# File 'lib/reportbuilder/image.rb', line 152

def image_magick
  Magick::Image.from_blob(@blob)
end