Sha256: 5108ac8a21c51a281b29cd1e0ba0c8c8812d16dcc0339d42aa53786340f4f329

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 Bytes

Contents

require 'base64'

module Gnawrnip
  class Publisher

    #
    # @params [Array]  images  Array of Gnawrnip::Image
    #
    def animation(images)
      images.map { |image| image_tag(image) }.join
    end

    #
    # @params [Gnawrnip::Image]  image
    #
    def single(image)
      image_tag(image)
    end

    private

      def image_tag(image, format = :png)
        width  = image.width
        height = image.height
        data   = image.to_base64
        %Q|<img width="#{width}" height="#{height}" src="data:image/#{format.to_s};base64,#{data}"/>|
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gnawrnip-0.2.5 lib/gnawrnip/publisher.rb
gnawrnip-0.2.4 lib/gnawrnip/publisher.rb
gnawrnip-0.2.3 lib/gnawrnip/publisher.rb