class Nucop::Helpers::CopSet
Public Class Methods
new(initial_cops = [])
click to toggle source
# File lib/nucop/helpers/cop_set.rb, line 6 def initialize(initial_cops = []) @cops = Set.new add_cops(initial_cops) @new_cop_added = false end
Public Instance Methods
add_cop(cop)
click to toggle source
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)
# File lib/nucop/helpers/cop_set.rb, line 21 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)
click to toggle source
# File lib/nucop/helpers/cop_set.rb, line 14 def add_cops(cops) cops.each(&method(:add_cop)) end
cop_added?()
click to toggle source
# File lib/nucop/helpers/cop_set.rb, line 35 def cop_added? @new_cop_added end
to_a()
click to toggle source
# File lib/nucop/helpers/cop_set.rb, line 31 def to_a @cops.to_a end
Private Instance Methods
find_department(cop)
click to toggle source
# File lib/nucop/helpers/cop_set.rb, line 41 def find_department(cop) return unless cop.include?("/") cop.split("/").first end