Class: Proc::Enumerator
- Inherits:
-
Object
- Object
- Proc::Enumerator
- Includes:
- Enumerable, Is::Inspectable
- Defined in:
- lib/proc/enumerator.rb
Instance Attribute Summary collapse
-
#next_block ⇒ Object
readonly
Returns the value of attribute next_block.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#each(enumerable = self, &block) ⇒ Object
- public
-
Calls the given block once for each value.
-
#initialize(values, &next_block) ⇒ Enumerator
constructor
A new instance of Enumerator.
Constructor Details
#initialize(values, &next_block) ⇒ Enumerator
Returns a new instance of Enumerator.
14 15 16 17 |
# File 'lib/proc/enumerator.rb', line 14 def initialize(values, &next_block) @values = values @next_block = next_block end |
Instance Attribute Details
#next_block ⇒ Object (readonly)
Returns the value of attribute next_block.
12 13 14 |
# File 'lib/proc/enumerator.rb', line 12 def next_block @next_block end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
12 13 14 |
# File 'lib/proc/enumerator.rb', line 12 def values @values end |
Instance Method Details
#each(enumerable = self, &block) ⇒ Object
- public
-
Calls the given block once for each value.
21 22 23 24 25 26 27 28 |
# File 'lib/proc/enumerator.rb', line 21 def each(enumerable = self, &block) return to_enum(:each) unless block while enumerable enumerable.values.each(&block) enumerable = enumerable.next_block&.call end end |