Sha256: 0504dc97e93d59a2c3d853ee01eca954ffeadc450c343055690c0b71978cbe0a
Contents?: true
Size: 670 Bytes
Versions: 5
Compression:
Stored size: 670 Bytes
Contents
require_relative 'string' class Array def combine_zips zips = [] start = nil last = nil self.sort.each do |zip| zip_int = zip.to_i if start == nil start = zip_int last = zip_int else if zip_int == last+1 last = zip_int else if last == start zips << start.to_zip else zips << "#{start.to_zip}-#{last.to_zip}" end start = zip_int last = zip_int end end end if last == start zips << start.to_zip else zips << "#{start.to_zip}-#{last.to_zip}" end zips.join "," end end
Version data entries
5 entries across 5 versions & 1 rubygems