Class: Judges::Categories
Overview
Categories of tests.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize(enable, disable) ⇒ Categories
constructor
Ctor.
-
#ok?(cats) ⇒ Boolean
This test is good to go, with this list of categories?.
Constructor Details
#initialize(enable, disable) ⇒ Categories
Ctor.
33 34 35 36 |
# File 'lib/judges/categories.rb', line 33 def initialize(enable, disable) @enable = enable.is_a?(Array) ? enable : [] @disable = disable.is_a?(Array) ? disable : [] end |
Instance Method Details
#ok?(cats) ⇒ Boolean
This test is good to go, with this list of categories?
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/judges/categories.rb', line 41 def ok?(cats) cats = [] if cats.nil? cats = [cats] unless cats.is_a?(Array) cats.each do |c| return false if @disable.any? { |d| d == c } return true if @enable.any? { |d| d == c } end return true if @enable.empty? false end |