Sha256: e405d8196b7e0c00012e40c3d1210846e801f699250d56320ab6ee2a04e10a11
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
module Kinu class Geometry AVAILABLE_TYPES = { width: :w, height: :h, quality: :q, crop: :c, original: :o, middle: :m, manual_crop: :mc, width_offset: :wo, height_offset: :ho, crop_width: :cw, crop_height: :ch, assumption_width: :aw, }.freeze def initialize(options) @options = options validate end def validate raise ArgumentError, "required geometry hash." if empty? return if !(@options[:width].nil? && @options[:height].nil?) return if @options[:middle] == true return if @options[:original] == true raise ArgumentError, <<-EOS invalid geometry, geometry must be met least one condition. - set width or height any numeric. - set middle true. - set original true. EOS end def empty? @options.empty? end def to_s geo = [] AVAILABLE_TYPES.each do |full_name, short_name| next if @options[full_name].nil? geo << "#{short_name}=#{@options[full_name]}" end geo.join(',') end end end
Version data entries
6 entries across 6 versions & 1 rubygems