lib/kanoko/application/convert/function.rb in kanoko-0.1.0 vs lib/kanoko/application/convert/function.rb in kanoko-0.1.1

- old
+ new

@@ -1,37 +1,50 @@ module Kanoko module Application class Convert + # You can make customize function. + # It just make or overwhrite instance method. + # example: + # class Kanoko::Application::Convert::Function + # # get "/new_func/new_value" + # # => add imagemagick option + # # -new-option new_value + # def new_func(arg) + # ['-new-option', arg] + # end + # end class Function - include Enumerable - extend Forwardable - def_delegators :@args, :each, :to_a, :to_h + class << self + def list + instance_methods(false) + end + end - def initialize(args) - @args = parse args + def crop(arg) + [ + '-crop', arg + ] end - def to_path - paths = [] - @args.each do |func, arg| - paths << "/#{func}/#{arg}" - end - paths.join + def fill(arg) + [ + '-gravity', 'north', + '-extent', arg, + '-background', 'transparent', + ] end - private + def resize(arg) + [ + '-define', "jpeg:size=#{arg}", + '-thumbnail', arg, + ] + end - def parse(args) - hash = {} - items = args.split('/') - items.each_slice(2) do |funcname, arg| - if funcname.match(/\./) - break - else - hash[funcname.to_sym] = arg.to_s - end - end - hash + def auto_orient + [ + '-auto-orient' + ] end end end end end