Class: Rinda::Tuple (Ruby 2.3.7)
Description: Class : Rinda::Tuple - Ruby 2.3.7

- Home
- Core 2.3.7
- Std-lib 2.3.7
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- rinda/rinda.rb

### Parent

Object

### Methods

- ::new
- #[]
- #each
- #fetch
- #size
- #value

### Class/Module Index

Quicksearch

- Rinda
- Rinda::DRbObjectTemplate
- Rinda::InvalidHashTupleKey
- Rinda::NotifyTemplateEntry
- Rinda::RequestCanceledError
- Rinda::RequestExpiredError
- Rinda::RindaError
- Rinda::RingFinger
- Rinda::RingProvider
- Rinda::RingServer
- Rinda::SimpleRenewer
- Rinda::Template
- Rinda::TemplateEntry
- Rinda::Tuple
- Rinda::TupleBag
- Rinda::TupleBag::TupleBin
- Rinda::TupleEntry
- Rinda::TupleSpace
- Rinda::TupleSpaceProxy
- Rinda::WaitTemplateEntry

No matching classes.

# Rinda::Tuple

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.

### Public Class Methods

new(ary_or_hash) click to toggle source

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

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

### Public Instance Methods

[](k) click to toggle source

Accessor method for elements of the tuple.

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

each() click to toggle source

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

                   # File 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) click to toggle source

Fetches item `k` from the tuple.

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

size() click to toggle source

The number of elements in the tuple.

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

value() click to toggle source

Return the tuple itself

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