Class: Nucop::Helpers::CopSet
- Inherits:
-
Object
- Object
- Nucop::Helpers::CopSet
- Defined in:
- lib/nucop/helpers/cop_set.rb
Instance Method Summary collapse
-
#add_cop(cop) ⇒ Object
add a single cop to the set if a cops department is already included, the cop is not added (it is part of the department already).
- #add_cops(cops) ⇒ Object
- #cop_added? ⇒ Boolean
-
#initialize(initial_cops = []) ⇒ CopSet
constructor
A new instance of CopSet.
- #to_a ⇒ Object
Constructor Details
#initialize(initial_cops = []) ⇒ CopSet
Returns a new instance of CopSet.
4 5 6 7 8 9 10 |
# File 'lib/nucop/helpers/cop_set.rb', line 4 def initialize(initial_cops = []) @cops = Set.new add_cops(initial_cops) @new_cop_added = false end |
Instance Method Details
#add_cop(cop) ⇒ Object
add a single cop to the set if a cops department is already included, the cop is not added (it is part of the department already)
19 20 21 22 23 24 25 26 27 |
# File 'lib/nucop/helpers/cop_set.rb', line 19 def add_cop(cop) department = find_department(cop) return if department && @cops.include?(department) return if @cops.include?(cop) @cops << cop @new_cop_added = true end |
#add_cops(cops) ⇒ Object
12 13 14 |
# File 'lib/nucop/helpers/cop_set.rb', line 12 def add_cops(cops) cops.each(&method(:add_cop)) end |
#cop_added? ⇒ Boolean
33 34 35 |
# File 'lib/nucop/helpers/cop_set.rb', line 33 def cop_added? @new_cop_added end |
#to_a ⇒ Object
29 30 31 |
# File 'lib/nucop/helpers/cop_set.rb', line 29 def to_a @cops.to_a end |