Class: Literal::Types::HashType
- Inherits:
-
Object
- Object
- Literal::Types::HashType
- Defined in:
- lib/literal/types/hash_type.rb
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(key_type, value_type) ⇒ HashType
constructor
A new instance of HashType.
- #inspect ⇒ Object
Constructor Details
#initialize(key_type, value_type) ⇒ HashType
Returns a new instance of HashType.
2 3 4 5 |
# File 'lib/literal/types/hash_type.rb', line 2 def initialize(key_type, value_type) @key_type = key_type @value_type = value_type end |
Instance Method Details
#===(value) ⇒ Object
11 12 13 |
# File 'lib/literal/types/hash_type.rb', line 11 def ===(value) value.is_a?(::Hash) && value.all? { |key, value| @key_type === key && @value_type === value } end |
#inspect ⇒ Object
7 8 9 |
# File 'lib/literal/types/hash_type.rb', line 7 def inspect "Hash(#{@key_type.inspect}, #{@value_type.inspect})" end |