Class Rinda::Tuple
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

Creates a new Tuple from ary_or_hash which must be an Array or Hash.

[Source]

    # File rinda/rinda.rb, line 51
51:     def initialize(ary_or_hash)
52:       if hash?(ary_or_hash)
53:         init_with_hash(ary_or_hash)
54:       else
55:         init_with_ary(ary_or_hash)
56:       end
57:     end

Public Instance methods

Accessor method for elements of the tuple.

[Source]

    # File 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.

[Source]

    # File 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.

[Source]

    # File rinda/rinda.rb, line 76
76:     def fetch(k)
77:       @tuple.fetch(k)
78:     end

The number of elements in the tuple.

[Source]

    # File rinda/rinda.rb, line 62
62:     def size
63:       @tuple.size
64:     end

Return the tuple itself

[Source]

    # File rinda/rinda.rb, line 94
94:     def value
95:       @tuple
96:     end

Search

Google

Ruby API Docs

Links