Module: Pione::TupleSpace::TupleDefinition
- Defined in:
- lib/pione/tuple-space/basic-tuple.rb
Instance Method Summary collapse
-
#any ⇒ TupleObject
Returns a respresentation for matching any tuples of same type.
-
#define_format(format) ⇒ void
Defines a tuple format and create a class representing it.
-
#delete_format(identifier) ⇒ void
Deletes a tuple format definition.
-
#domain_position ⇒ Integer?
private
Returns domain position of the format.
-
#format ⇒ Array
Returns tuple's format.
-
#identifier ⇒ Symbol
Returns the identifier.
-
#location_position ⇒ Integer or nil
private
Return location position of the format.
Instance Method Details
#any ⇒ TupleObject
Returns a respresentation for matching any tuples of same type.
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.
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_position ⇒ Integer?
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.
116 117 118 |
# File 'lib/pione/tuple-space/basic-tuple.rb', line 116 def domain_position position_of(:domain) || position_of(:domain_id) end |
#format ⇒ Array
Returns tuple's format.
94 95 96 |
# File 'lib/pione/tuple-space/basic-tuple.rb', line 94 def format @format end |
#identifier ⇒ Symbol
Returns the identifier.
101 102 103 |
# File 'lib/pione/tuple-space/basic-tuple.rb', line 101 def identifier @format.first end |
#location_position ⇒ Integer 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.
125 126 127 |
# File 'lib/pione/tuple-space/basic-tuple.rb', line 125 def location_position position_of(:location) end |