Class: MiniMagick2::CommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_magick.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, *options) ⇒ CommandBuilder

Returns a new instance of CommandBuilder.



359
360
361
362
363
# File 'lib/mini_magick.rb', line 359

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

#method_missing(symbol, *options) ⇒ Object



369
370
371
372
373
374
375
376
377
378
# File 'lib/mini_magick.rb', line 369

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(guessed_command_name, *options)
  else
    super(symbol, *args)
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



356
357
358
# File 'lib/mini_magick.rb', line 356

def args
  @args
end

#commandObject (readonly)

Returns the value of attribute command.



357
358
359
# File 'lib/mini_magick.rb', line 357

def command
  @command
end

Instance Method Details

#+(value) ⇒ Object

Deprecated.

Please don’t use the + method its has been deprecated



393
394
395
396
# File 'lib/mini_magick.rb', line 393

def +(value)
  warn "Warning: The MiniMagick2::ComandBuilder#+ command has been deprecated. Please use c << '+#{value}' instead"
  push "+#{value}"
end

#add(command, *options) ⇒ Object



380
381
382
383
384
385
# File 'lib/mini_magick.rb', line 380

def add(command, *options)
  push "-#{command}"
  if options.any?
    push "\"#{options.join(" ")}\""
  end
end

#push(arg) ⇒ Object Also known as: <<



387
388
389
# File 'lib/mini_magick.rb', line 387

def push(arg)
  @args << arg.to_s.strip
end