Sha256: 0c46751959199c636cfa76ee6961aa1af7d7983700431acf896abf06c1311a0d

Contents?: true

Size: 404 Bytes

Versions: 112

Compression:

Stored size: 404 Bytes

Contents

class Array
  def ids
    map(&:id)
  end

  def dups?
    find { |e| rindex(e) != index(e) } ? true : false
  end

  def dups
    (select { |e| rindex(e) != index(e) }).uniq
  end

  def dups_with_index
    return {} unless self.dups?
    hash = Hash.new { |h, k| h[k] = [] }
    each_with_index do |val, idx|
      hash[val] << idx
    end
    hash.delete_if { |_k, v| v.size == 1 }
    hash
  end
end

Version data entries

112 entries across 112 versions & 1 rubygems

Version Path
origen-0.24.0 lib/origen/core_ext/array.rb
origen-0.23.0 lib/origen/core_ext/array.rb
origen-0.22.0 lib/origen/core_ext/array.rb
origen-0.21.0 lib/origen/core_ext/array.rb
origen-0.20.3 lib/origen/core_ext/array.rb
origen-0.20.2 lib/origen/core_ext/array.rb
origen-0.20.1 lib/origen/core_ext/array.rb
origen-0.20.0 lib/origen/core_ext/array.rb
origen-0.13.0 lib/origen/core_ext/array.rb
origen-0.12.1 lib/origen/core_ext/array.rb
origen-0.12.0 lib/origen/core_ext/array.rb
origen-0.11.0 lib/origen/core_ext/array.rb
origen-0.10.1 lib/origen/core_ext/array.rb
origen-0.9.1 lib/origen/core_ext/array.rb
origen-0.9.0 lib/origen/core_ext/array.rb
origen-0.8.0 lib/origen/core_ext/array.rb
origen-0.7.47 lib/origen/core_ext/array.rb
origen-0.7.46 lib/origen/core_ext/array.rb
origen-0.7.45 lib/origen/core_ext/array.rb
origen-0.7.44 lib/origen/core_ext/array.rb