Sha256: abba45858249edf7d7b07dfec4d239ed9bbbfb94076e6046f37488781f5de25c
Contents?: true
Size: 852 Bytes
Versions: 2
Compression:
Stored size: 852 Bytes
Contents
class ImageOptim module OptionHelpers # Remove option from hash and run through block or return default def get_option!(options, name, default) value = default if options.has_key?(name) value = options.delete(name) value = yield(value) if block_given? end instance_variable_set("@#{name}", value) end # Ensure number is in range def limit_with_range(number, range) if range.include?(number) number elsif number < range.first range.first elsif range.exclude_end? range.last - 1 else range.last end end # Raise unless all options are deleted def assert_options_empty!(options) unless options.empty? raise ConfigurationError, "unknown options #{options.inspect} for #{self}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
image_optim-0.6.0 | lib/image_optim/option_helpers.rb |
image_optim-0.5.1 | lib/image_optim/option_helpers.rb |