Sha256: 47bb731c9773309778115955164542974883cfdbbed6004ae1b8365813665616

Contents?: true

Size: 392 Bytes

Versions: 1

Compression:

Stored size: 392 Bytes

Contents

require "base64"
require "cgi"

module Bumpspark
  
  module Formats
    
    module DataURI
    
      # Generate a Data URI
      # @see http://en.wikipedia.org/wiki/Data_URI_scheme
      #
      # @return [String]
      #
      def to_data_uri
        data = Base64.encode64(to_png).delete("\n")
        "data:image/png;base64,#{CGI.escape(data)}"
      end
    
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bumpspark-2.0.0 lib/bumpspark/formats/data_uri.rb