Class: SomethingLikeThat::Query

Inherits:
MatchPhrase show all
Defined in:
lib/something_like_that/match_phrase/query.rb

Overview

Holds a string phrase to be compared to other (candidate) MatchPhrases. Queries may be abbreviated/truncated; candidates should be complete.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MatchPhrase

#tokens

Constructor Details

#initialize(phrase) ⇒ Query



7
8
9
10
# File 'lib/something_like_that/match_phrase/query.rb', line 7

def initialize(phrase)
  super phrase
  @scorer = Scorer.new(self)
end

Instance Attribute Details

#scorerObject (readonly)

Returns the value of attribute scorer.



5
6
7
# File 'lib/something_like_that/match_phrase/query.rb', line 5

def scorer
  @scorer
end

Instance Method Details

#match(candidate) ⇒ Object



12
13
14
# File 'lib/something_like_that/match_phrase/query.rb', line 12

def match(candidate)
  scorer.score(MatchPhrase.new(candidate))
end

#match?(candidate) ⇒ Boolean



16
17
18
# File 'lib/something_like_that/match_phrase/query.rb', line 16

def match?(candidate)
  scorer.match?(MatchPhrase.new(candidate))
end