Class: Dragonfly::ImageMagick::Generators::Plain

Inherits:
Object
  • Object
show all
Includes:
ParamValidators
Defined in:
lib/dragonfly/image_magick/generators/plain.rb

Constant Summary

Constants included from ParamValidators

ParamValidators::IS_NUMBER, ParamValidators::IS_WORD, ParamValidators::IS_WORDS

Instance Method Summary collapse

Methods included from ParamValidators

is_number, is_word, is_words, validate!, validate_all!, validate_all_keys!

Instance Method Details

#call(content, width, height, opts = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/dragonfly/image_magick/generators/plain.rb', line 10

def call(content, width, height, opts = {})
  validate_all!([width, height], &is_number)
  validate_all_keys!(opts, %w(colour color format), &is_word)
  format = extract_format(opts)

  colour = opts["colour"] || opts["color"] || "white"
  Commands.generate(content, "-size #{width}x#{height} xc:#{colour}", format)
  content.add_meta("format" => format, "name" => "plain.#{format}")
end

#update_url(url_attributes, width, height, opts = {}) ⇒ Object



20
21
22
# File 'lib/dragonfly/image_magick/generators/plain.rb', line 20

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