Sha256: 2caa3ff97b51f5b8196e4d91685e8ba33c24da40732121b3a9729c29771cc864

Contents?: true

Size: 349 Bytes

Versions: 35

Compression:

Stored size: 349 Bytes

Contents

require "base64"

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

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

  def to_base64
    Base64.encode64(@data)
  end

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

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.16 lib/inline_image.rb
renalware-core-2.0.15 lib/inline_image.rb
renalware-core-2.0.14 lib/inline_image.rb
renalware-core-2.0.13 lib/inline_image.rb
renalware-core-2.0.12 lib/inline_image.rb
renalware-core-2.0.11 lib/inline_image.rb
renalware-core-2.0.9 lib/inline_image.rb
renalware-core-2.0.8 lib/inline_image.rb
renalware-core-2.0.7 lib/inline_image.rb
renalware-core-2.0.5 lib/inline_image.rb
renalware-core-2.0.4 lib/inline_image.rb
renalware-core-2.0.3 lib/inline_image.rb
renalware-core-2.0.2 lib/inline_image.rb
renalware-core-2.0.1 lib/inline_image.rb
renalware-core-2.0.0 lib/inline_image.rb
renalware-core-2.0.0.pre.rc13 lib/inline_image.rb
renalware-core-2.0.0.pre.rc11 lib/inline_image.rb
renalware-core-2.0.0.pre.rc10 lib/inline_image.rb
renalware-core-2.0.0.pre.rc9 lib/inline_image.rb
renalware-core-2.0.0.pre.rc8 lib/inline_image.rb