Class: Fried::Typings::HashOf
- Inherits:
-
Object
- Object
- Fried::Typings::HashOf
- Defined in:
- lib/fried/typings/hash_of.rb
Overview
Checks if all key => value elements of the hashmap match the types pair
Instance Method Summary collapse
-
#initialize(key_type, value_type) ⇒ HashOf
constructor
A new instance of HashOf.
- #valid?(hsh) ⇒ Boolean
Methods included from Type
Methods included from MetaType
Constructor Details
#initialize(key_type, value_type) ⇒ HashOf
Returns a new instance of HashOf.
21 22 23 24 |
# File 'lib/fried/typings/hash_of.rb', line 21 def initialize(key_type, value_type) @key_type = key_type @value_type = value_type end |
Instance Method Details
#valid?(hsh) ⇒ Boolean
27 28 29 30 31 32 33 |
# File 'lib/fried/typings/hash_of.rb', line 27 def valid?(hsh) return false unless Is[Hash].valid?(hsh) enumerator = hsh.each EnumeratorOf[TupleOf[key_type, value_type]].valid?(enumerator) end |