Class

Rinda::Template

Inheritance
< Rinda::Tuple < Object

Templates are used to match tuples in Rinda.

Methods

Instance

Visibility Signature
public === (tuple)
public match (tuple)

Instance Method Detail

===(tuple)

Alias for match.

match(tuple)

Matches this template against tuple. The tuple must be the same size as the template. An element with a nil value in a template acts as a wildcard, matching any value in the corresponding position in the tuple. Elements of the template match the tuple if the are #== or #===.

  Template.new([:foo, 5]).match   Tuple.new([:foo, 5]) # => true
  Template.new([:foo, nil]).match Tuple.new([:foo, 5]) # => true
  Template.new([String]).match    Tuple.new(['hello']) # => true

  Template.new([:foo]).match      Tuple.new([:foo, 5]) # => false
  Template.new([:foo, 6]).match   Tuple.new([:foo, 5]) # => false
  Template.new([:foo, nil]).match Tuple.new([:foo])    # => false
  Template.new([:foo, 6]).match   Tuple.new([:foo])    # => false