global
def position_hash(enum, interval)
positions it occupies in the Enumerable, optionally restricted to the
Returns a hash mapping each element of an Enumerable to the set of
def position_hash(enum, interval) string = enum.is_a?(String) hash = Hash.new { |h, k| h[k] = [] } interval.each do |i| k = string ? enum[i, 1] : enum[i] hash[k] << i end hash end