class Ame::Optional
Represents an optional argument to a {Method}. It has a {#default} value that will be used if no more arguments are available when it gets called upon to process an argument before the method this argument is associated with gets called. @api developer
Attributes
default[R]
@return [Object, nil] The default value of the receiver
Public Class Methods
new(name, default, description, &validate)
click to toggle source
@api internal @param (see Argument#initialize) @param [Object] default @yield (see Argument#initialize) @yieldparam (see Argument#initialize) @raise [ArgumentError] If the type of DEFAULT isn’t one that Ame
knows how
to parse
Calls superclass method
Ame::Argument::new
# File lib/ame-1.0/optional.rb, line 15 def initialize(name, default, description, &validate) @default = default super end
Private Instance Methods
parse(arguments)
click to toggle source
@api internal @return [Object] {#default} if ARGUMENTS#empty?, {super} otherwise
Calls superclass method
Ame::Argument#parse
# File lib/ame-1.0/optional.rb, line 27 def parse(arguments) arguments.empty? ? default : super end