summaryrefslogtreecommitdiff
path: root/app/models/license_status.rb
blob: d5da68f1f9347ec46629f0de229dc0af40d45f6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class LicenseStatus
  ACTIVE=Active.new
  EXPIRED=Expired.new
  CONFIDENTIAL=Confidential.new
  UNKNOWN=Object.new

  ALL=[ACTIVE, EXPIRED, CONFIDENTIAL]

  def self.find_match(status = "")
    ALL.find { |x| x.matches?("#{status}".downcase) } || ACTIVE
  end

  def self.status_for(license)
    ALL.find { |x| x.best_represents?(license) } || UNKNOWN
  end
end