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
- #+(*options) ⇒ Object
- #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.
381 382 383 384 385 |
# File 'lib/mini_magick.rb', line 381 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
391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/mini_magick.rb', line 391 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, *) self else super(symbol, *args) end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
378 379 380 |
# File 'lib/mini_magick.rb', line 378 def args @args end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
379 380 381 |
# File 'lib/mini_magick.rb', line 379 def command @command end |
Instance Method Details
#+(*options) ⇒ Object
403 404 405 406 407 408 409 410 |
# File 'lib/mini_magick.rb', line 403 def +(*) push(@args.pop.gsub /^-/, '+') if .any? .each do |o| push "\"#{ o }\"" end end end |
#add(command, *options) ⇒ Object
412 413 414 415 416 417 418 419 |
# File 'lib/mini_magick.rb', line 412 def add(command, *) push "-#{command}" if .any? .each do |o| push "\"#{ o }\"" end end end |
#push(arg) ⇒ Object Also known as: <<
421 422 423 |
# File 'lib/mini_magick.rb', line 421 def push(arg) @args << arg.to_s.strip end |