class NRSER::Types::EnumerableType
Type
class that parameterizes {Enumerable} values of a homogeneous type.
@example
array_of_int = NRSER::Types::EnumerableType.new Array, Integer array_of_int.test? [1, 2, 3] #=> true array_of_int.test? [1, 2, 'three'] #=> false array_of_int.test? 'blah' #=> false array_of_int.test? [] #=> true
Attributes
entry_type[R]
Type
all entries must satisfy.
@return [Type]
Public Class Methods
new(enumerable_type = ::Enumerable, entry_type = self.Top, **options)
click to toggle source
Instantiate a new `EnumerableType`.
Calls superclass method
# File lib/nrser/types/enumerables.rb, line 52 def initialize enumerable_type = ::Enumerable, entry_type = self.Top, **options super enumerable_type, **options @entry_type = Types.make entry_type end
Public Instance Methods
enumerable_type()
click to toggle source
Intuitive alias for {IsA#mod}.
@return [Class]
# File lib/nrser/types/enumerables.rb, line 77 def enumerable_type; mod; end
explain()
click to toggle source
@!group Display Instance Methods
# File lib/nrser/types/enumerables.rb, line 66 def explain "#{ enumerable_type.safe_name }<#{ entry_type.explain }>" end
test?(value)
click to toggle source
Calls superclass method
# File lib/nrser/types/enumerables.rb, line 80 def test? value # Test that `value` is of the right container class first return false unless super( value ) # If that passed test all the entries against the type value.all? &@entry_type.method( :test? ) end