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.
Instance Method Summary collapse
- #+(*options) ⇒ Object
- #add_command(command, *options) ⇒ Object
- #add_creation_operator(command, *options) ⇒ Object
- #command ⇒ Object
- #escape_string(value) ⇒ 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.
455 456 457 458 459 |
# File 'lib/mini_magick.rb', line 455 def initialize(tool, *) @tool = tool @args = [] .each { |arg| push(arg) } end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
453 454 455 |
# File 'lib/mini_magick.rb', line 453 def args @args end |
Instance Method Details
#+(*options) ⇒ Object
504 505 506 507 508 509 510 511 |
# File 'lib/mini_magick.rb', line 504 def +(*) push(@args.pop.gsub(/^-/, '+')) if .any? .each do |o| push escape_string(o) end end end |
#add_command(command, *options) ⇒ Object
513 514 515 516 517 518 519 520 |
# File 'lib/mini_magick.rb', line 513 def add_command(command, *) push "-#{command}" if .any? .each do |o| push escape_string(o) end end end |
#add_creation_operator(command, *options) ⇒ Object
526 527 528 529 530 531 532 533 534 |
# File 'lib/mini_magick.rb', line 526 def add_creation_operator(command, *) creation_command = command if .any? .each do |option| creation_command << ":#{option}" end end push creation_command end |
#command ⇒ Object
461 462 463 464 465 466 467 468 469 470 |
# File 'lib/mini_magick.rb', line 461 def command com = "#{@tool} #{@args.join(' ')}".strip com = "#{MiniMagick.processor} #{com}" unless MiniMagick.processor.nil? unless MiniMagick.processor_path.nil? seperator = MiniMagick.windows? ? "\\" : "/" com = "#{MiniMagick.processor_path}#{seperator}#{com}" end com.strip end |
#escape_string(value) ⇒ Object
522 523 524 |
# File 'lib/mini_magick.rb', line 522 def escape_string(value) Shellwords.escape(value.to_s) end |
#format(*options) ⇒ Object
493 494 495 |
# File 'lib/mini_magick.rb', line 493 def format(*) raise Error, "You must call 'format' on the image object directly!" end |
#push(arg) ⇒ Object Also known as: <<
536 537 538 |
# File 'lib/mini_magick.rb', line 536 def push(arg) @args << arg.to_s.strip end |