class Fried::Typings::EnumeratorOf

Checks if all enumerated objects {Is} of passed type

Attributes

type[R]

Public Class Methods

new(type) click to toggle source
# File lib/fried/typings/enumerator_of.rb, line 18
def initialize(type)
  @type = type
end

Public Instance Methods

valid?(enumerator) click to toggle source

Notice that the method will actually iterate over the enumerator @param enumerator [Enumerator]

# File lib/fried/typings/enumerator_of.rb, line 24
def valid?(enumerator)
  return false unless Is[Enumerator].valid?(enumerator)

  enumerator.all? { |obj| Is[type].valid?(obj) }
end