A tuple is the elementary object in Rinda programming. Tuples may be matched against templates if the tuple and the template are the same size.
Methods
Class Public methods
new(ary_or_hash)
Link
Source: show
# File lib/rinda/rinda.rb, line 51 def initialize(ary_or_hash) if hash?(ary_or_hash) init_with_hash(ary_or_hash) else init_with_ary(ary_or_hash) end end
Instance Public methods
[](k)
Link
Accessor method for elements of the tuple.
Source: show
# File lib/rinda/rinda.rb, line 69 def [](k) @tuple[k] end
each()
Link
Iterate through the tuple, yielding the index or key, and the value, thus ensuring arrays are iterated similarly to hashes.
Source: show
# File lib/rinda/rinda.rb, line 84 def each # FIXME if Hash === @tuple @tuple.each { |k, v| yield(k, v) } else @tuple.each_with_index { |v, k| yield(k, v) } end end
fetch(k)
Link
Fetches item k from the tuple.
Source: show
# File lib/rinda/rinda.rb, line 76 def fetch(k) @tuple.fetch(k) end