Sha256: 66d560fb4e86fe7a832442fe4c4803f829259cf7a1912ba19e490e6f21b61a4c

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

require "dragonfly/image_magick/commands"

module Dragonfly
  module ImageMagick
    module Generators
      class Plasma
        include ParamValidators

        def call(content, width, height, opts = {})
          validate_all!([width, height], &is_number)
          validate!(opts["format"], &is_word)
          format = extract_format(opts)
          Commands.generate(content, "-size #{width}x#{height} plasma:fractal", format)
          content.add_meta("format" => format, "name" => "plasma.#{format}")
        end

        def update_url(url_attributes, width, height, opts = {})
          url_attributes.name = "plasma.#{extract_format(opts)}"
        end

        private

        def extract_format(opts)
          opts["format"] || "png"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dragonfly-1.4.1 lib/dragonfly/image_magick/generators/plasma.rb
dragonfly-1.4.0 lib/dragonfly/image_magick/generators/plasma.rb