Class: Mal::HashT
Instance Method Summary
collapse
Methods inherited from OnlyT
#&, #|
Constructor Details
#initialize(**required_keys_to_matchers) ⇒ HashT
Returns a new instance of HashT.
101
102
103
|
# File 'lib/mal.rb', line 101
def initialize(**required_keys_to_matchers)
@required_keys_to_matchers = required_keys_to_matchers
end
|
Instance Method Details
#===(value) ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'lib/mal.rb', line 105
def ===(value)
return false unless value.is_a?(Hash)
@required_keys_to_matchers.each_pair do |k,value_matcher|
return false unless value.key? k
return false unless value_matcher === value[k]
end
true
end
|
#inspect ⇒ Object
114
115
116
|
# File 'lib/mal.rb', line 114
def inspect
'HashWith(%s)' % @required_keys_to_matchers.inspect[1..-2]
end
|