Rinda::Template (Class)

In: rinda/rinda.rb
Parent: Tuple

Templates are used to match tuples in Rinda.

Methods

===   match  

Public Instance methods

Alias for match.

[Source]

# File rinda/rinda.rb, line 113
    def ===(tuple)
      match(tuple)
    end

Perform the matching of a tuple against a template. An element with a nil value in a template acts as a wildcard, matching any value in the corresponding position in the tuple.

[Source]

# File rinda/rinda.rb, line 94
    def match(tuple)
      return false unless tuple.respond_to?(:size)
      return false unless tuple.respond_to?(:fetch)
      return false unless self.size == tuple.size
      each do |k, v|
        begin
          it = tuple.fetch(k)
        rescue
          return false
        end
        next if v.nil?
        next if v == it
        next if v === it
        return false
      end
      return true
    end

[Validate]