Class: IdentityParade::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/identity_parade/match.rb

Overview

The initial starting point for a matching.

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Match

Returns a new instance of Match.



6
7
8
9
# File 'lib/identity_parade/match.rb', line 6

def initialize(left, right)
  @left = left
  @right = right
end

Instance Method Details

#matcherClass

Returns The matcher class.

Returns:

  • (Class)

    The matcher class



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

def matcher
  matcher_class_name.constantize
end

#matcher_class_nameString

Returns the matcher class name.

Returns:

  • (String)

    the matcher class name



24
25
26
# File 'lib/identity_parade/match.rb', line 24

def matcher_class_name
  "identity_parade/matchers/#{@left.class.name.underscore}_matcher".classify
end

#scoreFloat

Returns the matching score.

Returns:

  • (Float)

    the matching score



12
13
14
15
16
# File 'lib/identity_parade/match.rb', line 12

def score
  return unless Kernel.const_defined?(matcher_class_name)

  matcher.new(@left, @right).score
end