Class: Clarus::Image
- Inherits:
-
Object
- Object
- Clarus::Image
- Defined in:
- lib/clarus/image.rb
Instance Method Summary collapse
- #encoded_image ⇒ Object
- #get_image_data ⇒ Object
- #get_image_dimensions ⇒ Object
-
#initialize(uri) ⇒ Image
constructor
A new instance of Image.
- #render ⇒ Object
Constructor Details
#initialize(uri) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 |
# File 'lib/clarus/image.rb', line 7 def initialize(uri) @image_path = uri get_image_data get_image_dimensions end |
Instance Method Details
#encoded_image ⇒ Object
21 22 23 |
# File 'lib/clarus/image.rb', line 21 def encoded_image @image_blob ||= Base64.encode64(get_image_data) end |
#get_image_data ⇒ Object
17 18 19 |
# File 'lib/clarus/image.rb', line 17 def get_image_data @image_data ||= open(@image_path).read end |
#get_image_dimensions ⇒ Object
13 14 15 |
# File 'lib/clarus/image.rb', line 13 def get_image_dimensions @image_size = ImageSize.new(get_image_data) end |
#render ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/clarus/image.rb', line 25 def render document_template = File.read(File.('../templates/image_template.erb', __FILE__)) filename = File.basename(@image_path) wordml_filename = "wordml://#{Time.now.to_i}#{filename}" Erubis::Eruby.new(document_template).result( :wordml_filename => wordml_filename, :width => @image_size.width, :height => @image_size.height, :filename => filename, :bindata => encoded_image ) end |