Method: Diff::LCS.__position_hash
- Defined in:
- lib/gems/diff-lcs-1.1.2/lib/diff/lcs.rb
.__position_hash(enum, interval = 0 .. -1)) ⇒ Object
Returns a hash mapping each element of an Enumerable to the set of positions it occupies in the Enumerable, optionally restricted to the elements specified in the range of indexes specified by interval.
923 924 925 926 927 928 929 930 |
# File 'lib/gems/diff-lcs-1.1.2/lib/diff/lcs.rb', line 923 def __position_hash(enum, interval = 0 .. -1) hash = Hash.new { |hh, kk| hh[kk] = [] } interval.each do |ii| kk = enum.kind_of?(String) ? enum[ii, 1] : enum[ii] hash[kk] << ii end hash end |