Class: JobParser::Match
- Inherits:
-
Object
- Object
- JobParser::Match
- Defined in:
- lib/jobparser/scorer.rb
Instance Attribute Summary collapse
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#str ⇒ Object
Returns the value of attribute str.
-
#worth ⇒ Object
Returns the value of attribute worth.
Instance Method Summary collapse
- #and_score_now ⇒ Object
- #if_block_true(&block) ⇒ Object
- #if_regex_match(reg, str) ⇒ Object
-
#initialize(str, worth, score = 0) ⇒ Match
constructor
A new instance of Match.
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
#score ⇒ Object (readonly)
Returns the value of attribute score.
36 37 38 |
# File 'lib/jobparser/scorer.rb', line 36 def score @score end |
#str ⇒ Object
Returns the value of attribute str.
35 36 37 |
# File 'lib/jobparser/scorer.rb', line 35 def str @str end |
#worth ⇒ Object
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_now ⇒ Object
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 |