Class: Rootage::Option

Inherits:
Item
  • Object
show all
Defined in:
lib/rootage/option.rb

Overview

Option is an option item for PIONE command.

Instance Method Summary collapse

Methods inherited from Item

#assign, #condition, #copy, #exception, #execute, #key, #process

Instance Method Details

#define_validator(&b) ⇒ Object



38
39
40
# File 'lib/rootage/option.rb', line 38

def define_validator(&b)
  self.validator = b
end

#setup(opt, cmd) ⇒ void

This method returns an undefined value.

Setup an OptionParser's option by this item.

Parameters:

  • opt (OptionParser)

    option parser

  • cmd (Command::PlainCommand)

    command object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rootage/option.rb', line 49

def setup(opt, cmd)
  if not(arg.nil?) and type.nil?
    raise OptionError.new(cmd, "Option type is undefined for the option " + inspect)
  end

  # build OptionParser#on arguments
  args = [short_for_optparse, long_for_optparse, desc].compact

  # call #on with the argument
  opt.on(*args) {|val| specify(cmd, val)}
end