Class: Literal::Types::HashType

Inherits:
Object
  • Object
show all
Defined in:
lib/literal/types/hash_type.rb

Instance Method Summary collapse

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

#inspectObject



7
8
9
# File 'lib/literal/types/hash_type.rb', line 7

def inspect
  "Hash(#{@key_type.inspect}, #{@value_type.inspect})"
end