1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

check hash tuple size

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
seki 2004-04-21 14:05:40 +00:00
parent 317547dc5d
commit fb3c76a225
3 changed files with 32 additions and 24 deletions

View file

@ -69,18 +69,15 @@ module Rinda
private
def init_with_ary(ary)
@tuple_size = ary.size
@tuple = Array.new(@tuple_size)
@tuple = Array.new(ary.size)
@tuple.size.times do |i|
@tuple[i] = ary[i]
end
end
def init_with_hash(hash)
@tuple_size = hash[:size]
@tuple = Hash.new
hash.each do |k, v|
next if k == :size
raise InvalidHashTupleKey unless String === k
@tuple[k] = v
end
@ -97,7 +94,7 @@ module Rinda
def match(tuple)
return false unless tuple.respond_to?(:size)
return false unless tuple.respond_to?(:fetch)
return false if @tuple_size && (@tuple_size != tuple.size)
return false unless self.size == tuple.size
each do |k, v|
begin
it = tuple.fetch(k)