Class: Ame::Arguments::Undefined
- Inherits:
-
Object
- Object
- Ame::Arguments::Undefined
- Defined in:
- lib/ame-1.0/arguments/undefined.rb
Overview
The arguments to a method in its 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.
Instance Method Summary collapse
-
#argument(name, type, description) {|?| ... } ⇒ self
Adds a new Ame::Argument to the receiver.
-
#define ⇒ Arguments
The defined version of the receiver.
-
#empty? ⇒ Boolean
True if now arguments have been added to the receiver.
-
#initialize ⇒ Undefined
constructor
A new instance of Undefined.
-
#optional(name, default, description) {|?| ... } ⇒ Optional
Adds a new Optional argument to the receiver.
-
#splat(name, type, description) {|?| ... } ⇒ Complete
Adds a new Splat to the receiver.
-
#splus(name, type, description) {|?| ... } ⇒ Complete
Adds a new Splus (required splat) to the receiver.
Constructor Details
#initialize ⇒ Undefined
Returns a new instance of Undefined.
11 12 13 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 11 def initialize @arguments = [] end |
Instance Method Details
#argument(name, type, description) {|?| ... } ⇒ self
Adds a new Ame::Argument to the receiver.
21 22 23 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 21 def argument(name, type, description, &validate) self << Ame::Argument.new(name, type, description, &validate) end |
#define ⇒ Arguments
Returns The defined version of the receiver.
61 62 63 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 61 def define Ame::Arguments.new(@arguments) end |
#empty? ⇒ Boolean
Returns True if now arguments have been added to the receiver.
56 57 58 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 56 def empty? @arguments.empty? end |
#optional(name, default, description) {|?| ... } ⇒ Optional
Adds a new Optional argument to the receiver.
31 32 33 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 31 def optional(name, default, description, &validate) Ame::Arguments::Optional.new(@arguments, Ame::Optional.new(name, default, description, &validate)) end |
#splat(name, type, description) {|?| ... } ⇒ Complete
Adds a new Splat to the receiver.
41 42 43 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 41 def splat(name, type, description, &validate) Ame::Arguments::Complete.new(@arguments, 'splat', Ame::Splat.new(name, type, description, &validate)) end |
#splus(name, type, description) {|?| ... } ⇒ Complete
Adds a new Splus (required splat) to the receiver.
51 52 53 |
# File 'lib/ame-1.0/arguments/undefined.rb', line 51 def splus(name, type, description, &validate) Ame::Arguments::Complete.new(@arguments, 'splus', Ame::Splus.new(name, type, description, &validate)) end |