Class: Judges::Categories

Inherits:
Object show all
Defined in:
lib/judges/categories.rb

Overview

Categories of tests.

Author

Yegor Bugayenko (yegor256@gmail.com)

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(enable, disable) ⇒ Categories

Ctor.

Parameters:

  • enable (Array<String>)

    List of categories to enable

  • disable (Array<String>)

    List of categories to enable



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?

Parameters:

  • cats (Array<String>)

    List of them

Returns:

  • (Boolean)

    True if yes



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