Class: MiniMagick::CommandBuilder
- Inherits:
-
Object
- Object
- MiniMagick::CommandBuilder
show all
- Defined in:
- lib/mini_magick.rb
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
Constructor Details
- (CommandBuilder) initialize(command, *options)
A new instance of CommandBuilder
447
448
449
450
451
|
# File 'lib/mini_magick.rb', line 447
def initialize(command, *options)
@command = command
@args = []
options.each { |arg| push(arg) }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(symbol, *options)
457
458
459
460
461
462
463
464
465
466
467
468
469
470
|
# File 'lib/mini_magick.rb', line 457
def method_missing(symbol, *options)
guessed_command_name = symbol.to_s.gsub('_','-')
if guessed_command_name == "format"
raise Error, "You must call 'format' on the image object directly!"
elsif MOGRIFY_COMMANDS.include?(guessed_command_name)
add_command(guessed_command_name, *options)
self
elsif IMAGE_CREATION_OPERATORS.include?(guessed_command_name)
add_creation_operator(guessed_command_name, *options)
self
else
super(symbol, *args)
end
end
|
Instance Attribute Details
- (Object) args
Returns the value of attribute args
444
445
446
|
# File 'lib/mini_magick.rb', line 444
def args
@args
end
|
- (Object) command
Returns the value of attribute command
445
446
447
|
# File 'lib/mini_magick.rb', line 445
def command
@command
end
|
Instance Method Details
- (Object) +(*options)
472
473
474
475
476
477
478
479
|
# File 'lib/mini_magick.rb', line 472
def +(*options)
push(@args.pop.gsub(/^-/, '+'))
if options.any?
options.each do |o|
push escape_string(o)
end
end
end
|
- (Object) add_command(command, *options)
481
482
483
484
485
486
487
488
|
# File 'lib/mini_magick.rb', line 481
def add_command(command, *options)
push "-#{command}"
if options.any?
options.each do |o|
push escape_string(o)
end
end
end
|
- (Object) add_creation_operator(command, *options)
494
495
496
497
498
499
500
501
502
|
# File 'lib/mini_magick.rb', line 494
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
|
- (Object) escape_string(value)
490
491
492
|
# File 'lib/mini_magick.rb', line 490
def escape_string(value)
Shellwords.escape(value.to_s)
end
|
- (Object) push(arg)
Also known as:
<<
504
505
506
|
# File 'lib/mini_magick.rb', line 504
def push(arg)
@args << arg.to_s.strip
end
|