Class: NRSER::Types::EnumerableType
- Defined in:
- lib/nrser/types/enumerables.rb
Overview
Type class that parameterizes Enumerable values of a homogeneous type.
Instance Attribute Summary collapse
-
#entry_type ⇒ Type
readonly
Type all entries must satisfy.
Attributes inherited from IsA
Display Instance Methods collapse
-
#explain ⇒ Object
————————————————————————.
Instance Method Summary collapse
-
#enumerable_type ⇒ Class
Intuitive alias for IsA#mod.
-
#initialize(enumerable_type = ::Enumerable, entry_type = self.Top, **options) ⇒ EnumerableType
constructor
Instantiate a new ‘EnumerableType`.
- #test?(value) ⇒ Boolean
Methods inherited from IsA
#==, #custom_from_data, #has_from_data?, #init_from_data?
Methods inherited from Type
#===, #builtin_inspect, #check, #check!, #default_name, #default_symbolic, #from_data, #from_s, #has_from_data?, #has_from_s?, #has_to_data?, #inspect, #intersection, #name, #not, #respond_to?, #symbolic, #test, #to_data, #to_proc, #to_s, #union, #xor
Constructor Details
#initialize(enumerable_type = ::Enumerable, entry_type = self.Top, **options) ⇒ EnumerableType
Instantiate a new ‘EnumerableType`.
52 53 54 55 56 57 |
# File 'lib/nrser/types/enumerables.rb', line 52 def initialize enumerable_type = ::Enumerable, entry_type = self.Top, ** super enumerable_type, ** @entry_type = Types.make entry_type end |
Instance Attribute Details
#entry_type ⇒ Type (readonly)
Type all entries must satisfy.
45 46 47 |
# File 'lib/nrser/types/enumerables.rb', line 45 def entry_type @entry_type end |
Instance Method Details
#enumerable_type ⇒ Class
Intuitive alias for IsA#mod.
77 |
# File 'lib/nrser/types/enumerables.rb', line 77 def enumerable_type; mod; end |
#explain ⇒ Object
66 67 68 |
# File 'lib/nrser/types/enumerables.rb', line 66 def explain "#{ enumerable_type.safe_name }<#{ entry_type.explain }>" end |
#test?(value) ⇒ Boolean
80 81 82 83 84 85 86 |
# 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 |