class R2do::Option

Public Class Methods

new(short, extended, description, callback) click to toggle source

Creates an instance of a Command

@param [String] short the short option name for this command @param [String] extended the full option name for this command @param [String] argument the optional argument for commands that have arguments @param [String] description the command’s description @param [callback] callback the callback method for this command

Calls superclass method
# File lib/r2do/command.rb, line 29
def initialize(short, extended, description, callback)
  super(short, extended, argument, description)

  if callback.nil?
    raise ArgumentError
  end

  @callback = callback
end

Public Instance Methods

execute(args) click to toggle source

Executes the callback of this command

@param [Array] args the collection of arguments @return [void]

# File lib/r2do/command.rb, line 43
def execute(args)
  @callback.call(args)
end