8000 minimagick/lib/mini_magick.rb at master · tdgs/minimagick · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
541 lines (478 loc) · 20.9 KB

mini_magick.rb

File metadata and controls

541 lines (478 loc) · 20.9 KB
# Example of what is generated here:
#
# def auto_orient(*options)
# add_command("auto-orient", *options)
# self
# end
# alias_method :"auto-orient", :auto_orient
dashed_command = mogrify_command.to_s.gsub("_","-")
underscored_command = mogrify_command.to_s.gsub("-","_")
define_method(underscored_command) do |*options|
add_command(__method__.to_s.gsub("_","-"), *options)
self
end
alias_method dashed_command, underscored_command
end
def format(*options)
raise Error, "You must call 'format' on the image object directly!"
end
IMAGE_CREATION_OPERATORS.each do |operator|
define_method operator do |*options|
add_creation_operator(__method__.to_s, *options)
self
end
end
def +(*options)
push(@args.pop.gsub(/^-/, '+'))
if options.any?
options.each do |o|
push escape_string(o)
end
end
end
def add_command(command, *options)
push "-#{command}"
if options.any?
options.each do |o|
push escape_string(o)
end
end
end
def escape_string(value)
Shellwords.escape(value.to_s)
end
def add_creation_operator(command, *options)
creation_command = command
if options.any?
options.each do |option|
creation_command << ":#{option}"
end
end
push creation_command
end
def push(arg)
@args << arg.to_s.strip
end
alias :<< :push
end
end
0