Sha256: 94d56a372377f4d8a5746008413aafa1693177af1c529b6121ecdf4fd8bc0127
Contents?: true
Size: 663 Bytes
Versions: 15
Compression:
Stored size: 663 Bytes
Contents
module Petrarca module Helpers extend self def split_to_parts(body, ranges) ranges.map do |range_str| s, e = range_str.split("-") prefix = body[0, s.size] if Range.new(s.to_i, e.to_i).cover?(prefix.to_i) [prefix, body[(prefix.size)..]] else nil end end.compact.first end def load_ranges(range_file) ranges = {} File.open(range_file, "r") do |f| f.each_line do |line| next if line.start_with?("#") g, r = line.chomp.split(":") ranges[g] = r.split(",") unless r.nil? end end ranges end end end
Version data entries
15 entries across 15 versions & 1 rubygems