Class: Ame::Methods

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ame-1.0/methods.rb

Overview

Stores #each Method defined on a Class.

Instance Method Summary collapse

Constructor Details

#initializeMethods

Returns a new instance of Methods.



8
9
10
# File 'lib/ame-1.0/methods.rb', line 8

def initialize
  @methods = {}
end

Instance Method Details

#<<(method) ⇒ self

Adds METHOD to the receiver

Parameters:

Returns:

  • (self)


15
16
17
18
# File 'lib/ame-1.0/methods.rb', line 15

def <<(method)
  @methods[method.name] = method
  self
end

#[](name) ⇒ Method

Returns The method NAME in the receiver.

Returns:

  • (Method)

    The method NAME in the receiver

Raises:



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

def [](name)
  @methods[name] or
    raise Ame::UnrecognizedMethod, 'unrecognized method: %s' % name
end

# {|option| ... } ⇒ Object #Enumerator<Method>

Overloads:

  • # {|option| ... } ⇒ Object

    Enumerates the methods.

    Yield Parameters:

  • #Enumerator<Method>

    Returns An Enumerator over the methods.

    Returns:

    • (Enumerator<Method>)

      An Enumerator over the methods



33
34
35
36
37
38
39
# File 'lib/ame-1.0/methods.rb', line 33

def each
  return enum_for(__method__) unless block_given?
  @methods.each_value do |method|
    yield method
  end
  self
end