Module: Pione::TupleSpace::TupleDefinition

Defined in:
lib/pione/tuple-space/basic-tuple.rb

Instance Method Summary collapse

Instance Method Details

#anyTupleObject

Returns a respresentation for matching any tuples of same type.

Returns:

  • (TupleObject)

    a query tuple that matches any tuples has the identifier



108
109
110
# File 'lib/pione/tuple-space/basic-tuple.rb', line 108

def any
  new
end

#define_format(format) ⇒ void

This method returns an undefined value.

Defines a tuple format and create a class representing it.

Raises:

  • (ScriptError)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pione/tuple-space/basic-tuple.rb', line 54

def define_format(format)
  raise ScriptError if @format
  @format = format

  identifier = format.first
  set_attr_accessors

  # check arguments: format is a list of symbols
  format.each do |name, _|
    unless Symbol === name
      raise TupleFormatError.new(name, identifier)
    end
  end

  # forbid to define same identifier and different format
  if TUPLE.has_key?(identifier)
    if not(TUPLE[identifier].format == format)
      raise TupleFormatError.new(format, identifier)
    else
      return TUPLE[identifier]
    end
  end

  # make a class and set it in a table
  TUPLE[identifier] = self
end

#delete_format(identifier) ⇒ void

This method returns an undefined value.

Deletes a tuple format definition.



83
84
85
86
87
88
89
# File 'lib/pione/tuple-space/basic-tuple.rb', line 83

def delete_format(identifier)
  if TUPLE.has_key?(identifier)
    name = TUPLE[identifier].name.split('::').last
    TUPLE.delete(identifier)
    remove_const(name)
  end
end

#domain_positionInteger?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns domain position of the format.

Returns:

  • (Integer, nil)

    position number of domain field, or nil



116
117
118
# File 'lib/pione/tuple-space/basic-tuple.rb', line 116

def domain_position
  position_of(:domain) || position_of(:domain_id)
end

#formatArray

Returns tuple's format.

Returns:

  • (Array)

    tuple's format



94
95
96
# File 'lib/pione/tuple-space/basic-tuple.rb', line 94

def format
  @format
end

#identifierSymbol

Returns the identifier.

Returns:

  • (Symbol)

    identifier of the tuple



101
102
103
# File 'lib/pione/tuple-space/basic-tuple.rb', line 101

def identifier
  @format.first
end

#location_positionInteger or nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return location position of the format.

Returns:

  • (Integer or nil)

    position number of location field, or nil



125
126
127
# File 'lib/pione/tuple-space/basic-tuple.rb', line 125

def location_position
  position_of(:location)
end