Class: Enumex::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/enumex/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#enumeratorObject (readonly)

Returns the value of attribute enumerator.



3
4
5
# File 'lib/enumex/base.rb', line 3

def enumerator
  @enumerator
end

Instance Method Details

#attach_to(enumerator, &block) ⇒ Object

Raises:

  • (TypeError)


5
6
7
8
9
10
11
12
# File 'lib/enumex/base.rb', line 5

def attach_to(enumerator, &block)
  raise TypeError unless enumerator.is_a?(Enumerator)

  @enumerator = enumerator
  @block = block

  actions.empty? ? self : run
end