Class: Ame::Optional

Inherits:
Argument show all
Defined in:
lib/ame-1.0/optional.rb

Overview

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

Instance Attribute Summary collapse

Attributes inherited from Argument

#description, #name

Instance Method Summary collapse

Methods inherited from Argument

#process, #to_s

Constructor Details

#initialize(name, default, description) {|?| ... } ⇒ Optional

Returns a new instance of Optional.

Parameters:

Yields:

  • (?)

Yield Parameters:

  • options (Hash<String, Object>)
  • processed (Array<String>)
  • argument (Object)

Raises:

  • If the type of DEFAULT isn’t one that Ame knows how to parse

API:

  • internal



16
17
18
19
# File 'lib/ame-1.0/optional.rb', line 16

def initialize(name, default, description, &validate)
  @default = default
  super
end

Instance Attribute Details

#defaultObject? (readonly)

Returns The default value of the receiver.

Returns:

  • The default value of the receiver

API:

  • developer



22
23
24
# File 'lib/ame-1.0/optional.rb', line 22

def default
  @default
end