You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

status.rb 619B

12345678910111213141516171819202122232425262728
  1. module CryptCheck
  2. module Status
  3. LEVELS = %i(critical error warning good perfect best).freeze
  4. PROBLEMS = %i(critical error warning).freeze
  5. def self.status(statuses)
  6. statuses = self.collect statuses
  7. self.select LEVELS, statuses
  8. end
  9. def self.problem(statuses)
  10. statuses = self.collect statuses
  11. self.select PROBLEMS, statuses
  12. end
  13. private
  14. def self.collect(statuses)
  15. first = statuses.first
  16. statuses = statuses.collect &:status if first.respond_to? :status
  17. statuses
  18. end
  19. def self.select(levels, statuses)
  20. return nil if statuses.empty?
  21. (levels & statuses).first
  22. end
  23. end
  24. end