Class: Hash::HashType

Inherits:
Object
  • Object
show all
Defined in:
lib/hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(key_type, value_type) ⇒ HashType

Returns a new instance of HashType.



3
4
5
6
# File 'lib/hash.rb', line 3

def initialize key_type, value_type
  @key_type = key_type
  @value_type = value_type
end

Instance Method Details

#is_type_of?(k, v) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/hash.rb', line 8

def is_type_of? k, v
  k.kind_of?(@key_type) and v.kind_of?(@value_type)
end

#to_sObject



12
13
14
# File 'lib/hash.rb', line 12

def to_s
  "Hash[#{@key_type}, #{@value_type}]"
end