Class: IDRegistry::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/idregistry/utils.rb

Overview

A set of general utility methods for the implementation. Clients may also have occasion to use these methods.

Class Method Summary collapse

Class Method Details

.matches?(pattern_, tuple_) ⇒ Boolean

Returns true if the given pattern is matched by the given tuple.

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/idregistry/utils.rb', line 50

def matches?(pattern_, tuple_)
  return false unless pattern_.size == tuple_.size
  tuple_.each_with_index do |tuple_elem_, index_|
    return false unless pattern_[index_] === tuple_elem_
  end
  return true
end