Module: Matchi

Defined in:
lib/matchi.rb,
lib/matchi/eql.rb,
lib/matchi/equal.rb,
lib/matchi/match.rb,
lib/matchi/be_nil.rb,
lib/matchi/be_true.rb,
lib/matchi/be_false.rb,
lib/matchi/raise_exception.rb

Overview

Namespace for the Matchi library.

Examples:

Match that 42 is equal to 42

matcher = Matchi.fetch(:Equal, 42)
matcher.matches? { 42 } # => true

Defined Under Namespace

Classes: BeFalse, BeNil, BeTrue, Eql, Equal, Match, RaiseException

Class Method Summary collapse

Class Method Details

.fetch(matcher_id, *args) ⇒ #matches?

Select a matcher from those available.

Parameters:

  • matcher_id (Symbol)

    The name of the constant of the matcher to fetch.

  • args (Array)

    Parameters to initialize the class of the matcher.

Returns:

  • (#matches?)

    the matcher



19
20
21
# File 'lib/matchi.rb', line 19

def self.fetch(matcher_id, *args)
  const_get(matcher_id, false).new(*args)
end