Class: Ame::Arguments
- Inherits:
-
Object
- Object
- Ame::Arguments
- Includes:
- Enumerable
- Defined in:
- lib/ame-1.0/arguments.rb
Overview
The arguments to a method in its defined state. Does the processing of arguments to the method and also enumerates #each of the arguments to the method for, for example, help output.
Defined Under Namespace
Classes: Complete, Optional, Undefined
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(arguments) ⇒ Arguments
constructor
A new instance of Arguments.
-
#process(options, arguments) ⇒ Array<Object>
The Ame::Argument#processed arguments.
Constructor Details
#initialize(arguments) ⇒ Arguments
Returns a new instance of Arguments.
10 11 12 |
# File 'lib/ame-1.0/arguments.rb', line 10 def initialize(arguments) @arguments = arguments end |
Instance Method Details
# {|argument| ... } ⇒ Object # ⇒ Enumerator<Argument>
37 38 39 40 41 42 43 |
# File 'lib/ame-1.0/arguments.rb', line 37 def each return enum_for(__method__) unless block_given? @arguments.each do |argument| yield argument end self end |
#process(options, arguments) ⇒ Array<Object>
Returns The Ame::Argument#processed arguments.
21 22 23 24 25 26 27 28 29 |
# File 'lib/ame-1.0/arguments.rb', line 21 def process(, arguments) unprocessed = arguments.dup reduce([]){ |processed, argument| processed << argument.process(, processed, unprocessed) }.tap{ raise Ame::SuperfluousArgument, 'superfluous arguments: %s' % unprocessed.join(' ') unless unprocessed.empty? } end |