class Pione::TupleSpace::TupleType
TupleType
represents tuple’s field data type. TupleType
has simple and complex form, the latter is consisted by types or-relation. The method +===+ is used by matching field data and type. @example
# create simple type simple_type = TupleType.new(String) simple_type === "abc" #=> true # create complex type complex_type = TupleType.new(String, Symbol) complex_type === "abc" #=> true complex_type === :abc #=> true
Public Class Methods
new(*types)
click to toggle source
Creates a tuple field type. @param [Array<Object>] types
tuple field types
# File lib/pione/tuple-space/basic-tuple.rb, line 26 def initialize(*types) raise ArgumentError.new(types) unless types.size > 0 @types = types end
Public Instance Methods
===(other)
click to toggle source
@api private
# File lib/pione/tuple-space/basic-tuple.rb, line 46 def ===(other) @types.find {|t| t === other} end
complex?()
click to toggle source
Returns true if the type is complex. @return [Boolean]
true if the type is complex, or false
# File lib/pione/tuple-space/basic-tuple.rb, line 41 def complex? not(simple?) end
simple?()
click to toggle source
Returns true if the type is simple. @return [Boolean]
true if the type is simple, or false
# File lib/pione/tuple-space/basic-tuple.rb, line 34 def simple? @types.size == 1 end