Class: IssueBeaver::Models::IssueMatcher
- Inherits:
-
Object
- Object
- IssueBeaver::Models::IssueMatcher
- Defined in:
- lib/issue_beaver/models/merger.rb
Defined Under Namespace
Classes: Match
Instance Method Summary collapse
- #find(todo) ⇒ Object
-
#find_and_check_off(todo) ⇒ Object
Won’t match the same issue twice for two different todos.
-
#initialize(issues) ⇒ IssueMatcher
constructor
A new instance of IssueMatcher.
Constructor Details
#initialize(issues) ⇒ IssueMatcher
Returns a new instance of IssueMatcher.
70 71 72 73 |
# File 'lib/issue_beaver/models/merger.rb', line 70 def initialize(issues) @issues = issues @found_issues = [] end |
Instance Method Details
#find(todo) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/issue_beaver/models/merger.rb', line 84 def find(todo) best_match = all_matches(todo).sort_by(&:degree).first if best_match && best_match.sane? best_match else nil end end |
#find_and_check_off(todo) ⇒ Object
Won’t match the same issue twice for two different todos
77 78 79 80 81 |
# File 'lib/issue_beaver/models/merger.rb', line 77 def find_and_check_off(todo) find(todo).tap do |match| @found_issues.push match.issue if match end end |