class Ame::Option

Represents an option to a {Method} that takes an argument. If an explicit (‘=’-separated) argument is given, it’ll be used, otherwise the following argument will be used. @api developer

Public Class Methods

new(short, long, argument, default, description, &validate) click to toggle source

@api internal @param (see Switch#initialize) @yield (see Switch#initialize) @yieldparam (see Switch#initialize) @raise (see Flag#initialize) @raise [ArgumentError] If the type of DEFAULT isn’t one that Ame knows how

to parse
Calls superclass method Ame::Switch::new
# File lib/ame-1.0/option.rb, line 14
def initialize(short, long, argument, default, description, &validate)
  super short, long, argument, default, nil, description, &validate
end

Public Instance Methods

process_combined(options, arguments, name, remainder) click to toggle source

Invokes {Flag#process} with REMAINDER as the explicit argument if it’s non-empty. @api internal @param (see Flag#process_combined) @return [[Boolean, ”]]

# File lib/ame-1.0/option.rb, line 23
def process_combined(options, arguments, name, remainder)
  [process(options, arguments, name, remainder.empty? ? nil : remainder), '']
end

Private Instance Methods

parse(arguments, explicit) click to toggle source

@api internal @param (see Flag#parse) @return [Object] The parsed value of EXPLICIT, if non-nil, the next argument otherwise @raise [MissingArgument] If EXPLICIT is nil and there are no more arguments

# File lib/ame-1.0/option.rb, line 33
def parse(arguments, explicit)
  @type.parse(explicit || arguments.shift || raise(Ame::MissingArgument, 'missing argument: %s' % self))
end