Rinda::Tuple (Class)

In: rinda/rinda.rb
Parent: Object

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

[]   each   fetch   new   size   value  

Public Class methods

Initialize a tuple with an Array or a Hash.

[Source]

# File rinda/rinda.rb, line 33
    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

Public Instance methods

Accessor method for elements of the tuple.

[Source]

# File rinda/rinda.rb, line 47
    def [](k)
      @tuple[k]
    end

Iterate through the tuple, yielding the index or key, and the value, thus ensuring arrays are iterated similarly to hashes.

[Source]

# File rinda/rinda.rb, line 57
    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

[Source]

# File rinda/rinda.rb, line 51
    def fetch(k)
      @tuple.fetch(k)
    end

The number of elements in the tuple.

[Source]

# File rinda/rinda.rb, line 42
    def size
      @tuple.size
    end

Return the tuple itself — i.e the Array or hash.

[Source]

# File rinda/rinda.rb, line 66
    def value
      @tuple
    end

[Validate]