class JobParser::Scorer

Attributes

matches[R]

Public Class Methods

new() click to toggle source
# File lib/jobparser/scorer.rb, line 5
def initialize
  @matches = {}
end

Public Instance Methods

score_for(str) click to toggle source
# File lib/jobparser/scorer.rb, line 20
def score_for(str)
  @matches[str].nil? ? 0 : @matches[str].score
end
store(str, worth) click to toggle source
# File lib/jobparser/scorer.rb, line 9
def store(str, worth)
  match = nil
  if match = @matches[str]
    match = Match.new(str, worth, match.score)
  else
    match = Match.new(str, worth)
  end
  @matches[str] = match
  match
end
store_and_score(str, worth) click to toggle source
# File lib/jobparser/scorer.rb, line 28
def store_and_score(str, worth)
  store(str, worth).and_score_now
end
top_match() click to toggle source
# File lib/jobparser/scorer.rb, line 24
def top_match
  @matches.select { |k, v| v.score > 0 }.max_by { |k, v| v.score }.first
end