Class: InlineImage

Inherits:
Object
  • Object
show all
Defined in:
lib/inline_image.rb

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ InlineImage

Returns a new instance of InlineImage.



6
7
8
9
# File 'lib/inline_image.rb', line 6

def initialize(file_path)
  @filename = File.join(Renalware::Engine.root, file_path)
  @data = File.read(@filename)
end

Instance Method Details

#mime_typeObject



19
20
21
# File 'lib/inline_image.rb', line 19

def mime_type
  MIME::Types.type_for(@filename).first.to_s
end

#srcObject



11
12
13
# File 'lib/inline_image.rb', line 11

def src
  "data:#{mime_type};base64,#{to_base64}"
end

#to_base64Object



15
16
17
# File 'lib/inline_image.rb', line 15

def to_base64
  Base64.encode64(@data)
end