Class: JobParser::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/jobparser/scorer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, worth, score = 0) ⇒ Match

Returns a new instance of Match.



37
38
39
40
41
# File 'lib/jobparser/scorer.rb', line 37

def initialize(str, worth, score = 0)
  @str = str
  @score = score
  @worth = worth
end

Instance Attribute Details

#scoreObject (readonly)

Returns the value of attribute score.



36
37
38
# File 'lib/jobparser/scorer.rb', line 36

def score
  @score
end

#strObject

Returns the value of attribute str.



35
36
37
# File 'lib/jobparser/scorer.rb', line 35

def str
  @str
end

#worthObject

Returns the value of attribute worth.



35
36
37
# File 'lib/jobparser/scorer.rb', line 35

def worth
  @worth
end

Instance Method Details

#and_score_nowObject



57
58
59
60
# File 'lib/jobparser/scorer.rb', line 57

def and_score_now
  @score += @worth
  self
end

#if_block_true(&block) ⇒ Object



51
52
53
54
55
# File 'lib/jobparser/scorer.rb', line 51

def if_block_true(&block)
  res = yield
  @score += @worth if res
  res
end

#if_regex_match(reg, str) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/jobparser/scorer.rb', line 43

def if_regex_match(reg, str)
  reg.match(str) {
    @score += @worth
    true
  }
  false
end