class T::HashType

Attributes

key_type[R]
value_type[R]

Public Class Methods

new(key_type, value_type) click to toggle source
# File lib/emery/type.rb, line 88
def initialize(key_type, value_type)
  @key_type = key_type
  @value_type = value_type
end

Public Instance Methods

==(other) click to toggle source
# File lib/emery/type.rb, line 105
def ==(other)
  T.instance_of?(HashType, other) and self.key_type == other.key_type and self.value_type == other.value_type
end
check(value) click to toggle source
# File lib/emery/type.rb, line 95
def check(value)
  T.check_not_nil(self, value)
  if !value.is_a? Hash
    raise TypeError.new("Value '#{value.inspect.to_s}' type is #{value.class} - Hash is required")
  end
  value.each do |item_key, item_value|
    T.check(@key_type, item_key)
    T.check(@value_type, item_value)
  end
end
to_s() click to toggle source
# File lib/emery/type.rb, line 92
def to_s
  "Hash[#{@key_type.to_s}, #{@value_type.to_s}]"
end