Class: Fried::Typings::ArrayOf
- Inherits:
-
Object
- Object
- Fried::Typings::ArrayOf
- Defined in:
- lib/fried/typings/array_of.rb
Overview
Checks if all elements of the array match given type
Instance Method Summary collapse
-
#initialize(type) ⇒ ArrayOf
constructor
A new instance of ArrayOf.
- #valid?(ary) ⇒ Boolean
Methods included from Type
Methods included from MetaType
Constructor Details
#initialize(type) ⇒ ArrayOf
Returns a new instance of ArrayOf.
19 20 21 |
# File 'lib/fried/typings/array_of.rb', line 19 def initialize(type) @type = type end |
Instance Method Details
#valid?(ary) ⇒ Boolean
24 25 26 27 28 29 30 |
# File 'lib/fried/typings/array_of.rb', line 24 def valid?(ary) return false unless Is[Array].valid?(ary) enumerator = ary.each EnumeratorOf[type].valid?(enumerator) end |