Class: IssueBeaver::Models::IssueMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/issue_beaver/models/merger.rb

Defined Under Namespace

Classes: Match

Instance Method Summary collapse

Constructor Details

#initialize(issues) ⇒ IssueMatcher

Returns a new instance of IssueMatcher.



85
86
87
88
# File 'lib/issue_beaver/models/merger.rb', line 85

def initialize(issues)
  @issues = issues
  @found_issues = []
end

Instance Method Details

#find(todo) ⇒ Object



99
100
101
102
103
104
105
106
# File 'lib/issue_beaver/models/merger.rb', line 99

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



92
93
94
95
96
# File 'lib/issue_beaver/models/merger.rb', line 92

def find_and_check_off(todo)
  find(todo).tap do |match|
    @found_issues.push match.issue if match
  end
end