Class: InlineImage
- Inherits:
-
Object
- Object
- InlineImage
- Defined in:
- lib/inline_image.rb
Instance Method Summary collapse
-
#initialize(file_path) ⇒ InlineImage
constructor
A new instance of InlineImage.
- #mime_type ⇒ Object
- #src ⇒ Object
- #to_base64 ⇒ Object
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_type ⇒ Object
19 20 21 |
# File 'lib/inline_image.rb', line 19 def mime_type MIME::Types.type_for(@filename).first.to_s end |
#src ⇒ Object
11 12 13 |
# File 'lib/inline_image.rb', line 11 def src "data:#{mime_type};base64,#{to_base64}" end |
#to_base64 ⇒ Object
15 16 17 |
# File 'lib/inline_image.rb', line 15 def to_base64 Base64.encode64(@data) end |