Class: MiniMagick::CommandBuilder
- Inherits:
-
Object
- Object
- MiniMagick::CommandBuilder
- Defined in:
- lib/mini_magick.rb
Instance Method Summary collapse
- #+(*options) ⇒ Object
- #add_command(command, *options) ⇒ Object
- #add_creation_operator(command, *options) ⇒ Object
- #args ⇒ Object
- #command ⇒ Object
- #format(*options) ⇒ Object
-
#initialize(tool, *options) ⇒ CommandBuilder
constructor
A new instance of CommandBuilder.
- #push(arg) ⇒ Object (also: #<<)
Constructor Details
#initialize(tool, *options) ⇒ CommandBuilder
Returns a new instance of CommandBuilder.
435 436 437 438 439 |
# File 'lib/mini_magick.rb', line 435 def initialize(tool, *) @tool = tool @args = [] .each { |arg| push(arg) } end |
Instance Method Details
#+(*options) ⇒ Object
485 486 487 488 489 490 491 492 |
# File 'lib/mini_magick.rb', line 485 def +(*) push(@args.pop.gsub(/^-/, '+')) if .any? .each do |o| push o end end end |
#add_command(command, *options) ⇒ Object
494 495 496 497 498 499 500 501 |
# File 'lib/mini_magick.rb', line 494 def add_command(command, *) push "-#{command}" if .any? .each do |o| push o end end end |
#add_creation_operator(command, *options) ⇒ Object
503 504 505 506 507 508 509 510 511 |
# File 'lib/mini_magick.rb', line 503 def add_creation_operator(command, *) creation_command = command if .any? .each do |option| creation_command << ":#{option}" end end push creation_command end |
#args ⇒ Object
449 450 451 |
# File 'lib/mini_magick.rb', line 449 def args @args.map(&:shellescape) end |
#command ⇒ Object
441 442 443 444 445 446 447 |
# File 'lib/mini_magick.rb', line 441 def command com = "#{@tool} #{args.join(' ')}".strip com = "#{MiniMagick.processor} #{com}" unless MiniMagick.processor.nil? com = File.join MiniMagick.processor_path, com unless MiniMagick.processor_path.nil? com.strip end |
#format(*options) ⇒ Object
474 475 476 |
# File 'lib/mini_magick.rb', line 474 def format(*) raise Error, "You must call 'format' on the image object directly!" end |
#push(arg) ⇒ Object Also known as: <<
513 514 515 |
# File 'lib/mini_magick.rb', line 513 def push(arg) @args << arg.to_s.strip end |