lib/gziprb/deflate.rb
def to_groups_from_runs(runs)
        runs.flat_map do |value, count|
          min, max = value.zero? ? [3, 138] : [4, 6]

          [].tap do |groups|
            while count > max
              groups << [value, max]
              count -= max
            end

            if count < min
              count.times { groups << [value, 1] }
            else
              groups << [value, count]
            end
          end
        end
      end
# Breaks runs of elements into groups that are valid by the above encoding. We break up
# large groups into smaller groups, and too-small groups into single element groups.
Breaks runs of elements into groups that are valid by the above encoding. We break up
large groups into smaller groups, and too-small groups into single element groups.
Breaks runs of elements into groups that are valid by the above encoding . We break up large groups into smaller groups and too - small groups into single element groups .
def to_groups_from_runs(runs)
        runs.flat_map do |value, count|
          min, max = value.zero? ? [3, 138] : [4, 6]
          [].tap do |groups|
            while count > max
              groups << [value, max]
              count -= max
            end
            if count < min
              count.times { groups << [value, 1] }
            else
              groups << [value, count]
            end
          end
        end
      end
def to_groups_from_runs ( runs ) runs . flat_map do | value , count | min , max = value . zero? ? [ 3 , 138 ] : [ 4 , 6 ] [ ] . tap do | groups | while count > max groups << [ value , max ] count -= max end if count < min count . times { groups << [ value , 1 ] } else groups << [ value , count ] end end end end
Breaks runs of elements into groups that are valid by the above encoding.
Breaks runs of elements into groups that are valid by the above encoding .
runs