class Ame::Arguments::Undefined
The arguments to a method in its {Method::Undefined undefined state} before any optional or splat/splus arguments have been defined. When an {#optional} argument has been added, it’ll enter an {Optional} state where only additional {#optional} and {#splat} arguments are allowed. When a {#splat} or {#splus} has been added, it’ll enter a {Complete} state where no additional arguments are allowed. @api internal
Public Class Methods
# File lib/ame-1.0/arguments/undefined.rb, line 10 def initialize @arguments = [] end
Public Instance Methods
Adds a new {Argument} to the receiver. @param (see Argument#initialize) @yield (see Argument#initialize) @yieldparam (see Argument#initialize) @raise (see Argument#initialize) @return [self]
# File lib/ame-1.0/arguments/undefined.rb, line 20 def argument(name, type, description, &validate) self << Ame::Argument.new(name, type, description, &validate) end
@return [Arguments] The defined version of the receiver
# File lib/ame-1.0/arguments/undefined.rb, line 60 def define Ame::Arguments.new(@arguments) end
@return True if now arguments have been added to the receiver
# File lib/ame-1.0/arguments/undefined.rb, line 55 def empty? @arguments.empty? end
Adds a new {Optional} argument to the receiver. @param (see Ame::Optional#initialize) @yield (see Ame::Optional#initialize) @yieldparam (see Ame::Optional#initialize) @raise (see Ame::Optional#initialize) @return [Optional]
# File lib/ame-1.0/arguments/undefined.rb, line 30 def optional(name, default, description, &validate) Ame::Arguments::Optional.new(@arguments, Ame::Optional.new(name, default, description, &validate)) end
Adds a new {Splat} to the receiver. @param (see Argument#initialize) @yield (see Argument#initialize) @yieldparam (see Argument#initialize) @raise (see Argument#initialize) @return [Complete]
# File lib/ame-1.0/arguments/undefined.rb, line 40 def splat(name, type, description, &validate) Ame::Arguments::Complete.new(@arguments, 'splat', Ame::Splat.new(name, type, description, &validate)) end
Adds a new {Splus} (required splat) to the receiver. @param (see Argument#initialize) @yield (see Argument#initialize) @yieldparam (see Argument#initialize) @raise (see Argument#initialize) @return [Complete]
# File lib/ame-1.0/arguments/undefined.rb, line 50 def splus(name, type, description, &validate) Ame::Arguments::Complete.new(@arguments, 'splus', Ame::Splus.new(name, type, description, &validate)) end
Protected Instance Methods
# File lib/ame-1.0/arguments/undefined.rb, line 66 def <<(argument) @arguments << argument self end