Class: SomethingLikeThat::Query
- Inherits:
-
MatchPhrase
- Object
- String
- MatchPhrase
- SomethingLikeThat::Query
- 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
-
#scorer ⇒ Object
readonly
Returns the value of attribute scorer.
Instance Method Summary collapse
-
#initialize(phrase) ⇒ Query
constructor
A new instance of Query.
- #match(candidate) ⇒ Object
- #match?(candidate) ⇒ Boolean
Methods inherited from MatchPhrase
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
#scorer ⇒ Object (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 |