Class: MiniMagick::CommandBuilder
- Inherits:
-
Object
- Object
- MiniMagick::CommandBuilder
- Defined in:
- lib/mini_magick.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#+(value) ⇒ Object
deprecated
Deprecated.
Please don’t use the + method its has been deprecated
- #add(command, *options) ⇒ Object
-
#initialize(command, *options) ⇒ CommandBuilder
constructor
A new instance of CommandBuilder.
- #method_missing(symbol, *options) ⇒ Object
- #push(arg) ⇒ Object (also: #<<)
Constructor Details
#initialize(command, *options) ⇒ CommandBuilder
Returns a new instance of CommandBuilder.
423 424 425 426 427 |
# File 'lib/mini_magick.rb', line 423 def initialize(command, *) @command = command @args = [] .each { |arg| push(arg) } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *options) ⇒ Object
433 434 435 436 437 438 439 440 441 442 |
# File 'lib/mini_magick.rb', line 433 def method_missing(symbol, *) 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(guessed_command_name, *) else super(symbol, *args) end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
420 421 422 |
# File 'lib/mini_magick.rb', line 420 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
421 422 423 |
# File 'lib/mini_magick.rb', line 421 def command @command end |
Instance Method Details
#+(value) ⇒ Object
Deprecated.
Please don’t use the + method its has been deprecated
457 458 459 460 |
# File 'lib/mini_magick.rb', line 457 def +(value) warn "Warning: The MiniMagick::ComandBuilder#+ command has been deprecated. Please use c << '+#{value}' instead" push "+#{value}" end |
#add(command, *options) ⇒ Object
444 445 446 447 448 449 |
# File 'lib/mini_magick.rb', line 444 def add(command, *) push "-#{command}" if .any? push "\"#{.join(" ")}\"" end end |
#push(arg) ⇒ Object Also known as: <<
451 452 453 |
# File 'lib/mini_magick.rb', line 451 def push(arg) @args << arg.to_s.strip end |