Class: Ccs::Conflicts

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/conflict/calendars.rb

Instance Method Summary collapse

Constructor Details

#initialize(*calendars) ⇒ Conflicts

Returns a new instance of Conflicts.



22
23
24
25
# File 'lib/conflict/calendars.rb', line 22

def initialize(*calendars)
	@calendars = calendars
	compute!
end

Instance Method Details

#compute!Object



31
32
33
34
35
36
37
38
# File 'lib/conflict/calendars.rb', line 31

def compute!
	result = @calendars.combination(2).to_a.map do |comb|
		calendar_first = comb.first
		calendar_last = comb.last
		comb if overlaps(calendar_first.start_time,calendar_first.end_time,calendar_last.start_time,calendar_last.end_time)
	end.compact
	@conflicts = Graph.new(result).find_maximum_cliques
end

#each(&block) ⇒ Object



40
41
42
# File 'lib/conflict/calendars.rb', line 40

def each(&block)                      
  @conflicts.each(&block)       
end

#inspectObject



27
28
29
# File 'lib/conflict/calendars.rb', line 27

def inspect
  "#<Ccs::Conflict:#{'0x00%x' % (object_id << 1)} {#{@conflicts.size}}>"
end

#sizeObject



44
45
46
# File 'lib/conflict/calendars.rb', line 44

def size
	@conflicts.size
end