Sha256: 6d29356de2dd3db5fb6df16782a90e4a3a0307d607272e5155c67573d77c6bba
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
module Overlap class Detect attr_reader :overlaps def initialize(collection) @collection = collection @overlaps = [] build! end private def build! destructive_collection = @collection.dup.to_a current_segment = nil while (one = destructive_collection.shift) do current_segment = Segment.new(one.start_position, one.end_position) segments = [] segments << one @collection.map do |other| next if current_segment.same?(other) if current_segment.overlap?(other) current_segment.merge!(other) segments << other end end.compact segments.each { |e| @collection.delete(e) } segments.each { |e| destructive_collection.delete(e) } @overlaps << { union: current_segment, segments: segments } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
overlap-0.2.0 | lib/overlap/detect.rb |