Class: Enumerator

Inherits:
Object show all
Defined in:
lib/eac_ruby_utils/patches/enumerator/current.rb,
lib/eac_ruby_utils/patches/enumerator/stopped.rb

Instance Method Summary collapse

Instance Method Details

#current(default_value = nil) ⇒ Object


4
5
6
7
8
# File 'lib/eac_ruby_utils/patches/enumerator/current.rb', line 4

def current(default_value = nil)
  peek
rescue ::StopIteration
  default_value
end

#ongoing?Boolean

Returns:

  • (Boolean)

4
5
6
# File 'lib/eac_ruby_utils/patches/enumerator/stopped.rb', line 4

def ongoing?
  !stopped?
end

#stopped?Boolean

Returns:

  • (Boolean)

8
9
10
11
12
13
# File 'lib/eac_ruby_utils/patches/enumerator/stopped.rb', line 8

def stopped?
  peek
  false
rescue ::StopIteration
  true
end