Class: Ccs::Conflicts
- Inherits:
-
Object
- Object
- Ccs::Conflicts
- Includes:
- Enumerable
- Defined in:
- lib/conflict/calendars.rb
Instance Method Summary collapse
- #compute! ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(*calendars) ⇒ Conflicts
constructor
A new instance of Conflicts.
- #inspect ⇒ Object
- #size ⇒ Object
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 |
#inspect ⇒ Object
27 28 29 |
# File 'lib/conflict/calendars.rb', line 27 def inspect "#<Ccs::Conflict:#{'0x00%x' % (object_id << 1)} {#{@conflicts.size}}>" end |
#size ⇒ Object
44 45 46 |
# File 'lib/conflict/calendars.rb', line 44 def size @conflicts.size end |