Class | Rinda::Tuple |
In: |
lib/rinda/rinda.rb
|
Parent: | Object |
Accessor method for elements of the tuple.
# File lib/rinda/rinda.rb, line 69 69: def [](k) 70: @tuple[k] 71: end
Iterate through the tuple, yielding the index or key, and the value, thus ensuring arrays are iterated similarly to hashes.
# File lib/rinda/rinda.rb, line 84 84: def each # FIXME 85: if Hash === @tuple 86: @tuple.each { |k, v| yield(k, v) } 87: else 88: @tuple.each_with_index { |v, k| yield(k, v) } 89: end 90: end
Fetches item k from the tuple.
# File lib/rinda/rinda.rb, line 76 76: def fetch(k) 77: @tuple.fetch(k) 78: end
The number of elements in the tuple.
# File lib/rinda/rinda.rb, line 62 62: def size 63: @tuple.size 64: end
# File lib/rinda/rinda.rb, line 100 100: def hash?(ary_or_hash) 101: ary_or_hash.respond_to?(:keys) 102: end