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.2.0 lib/origen/core_ext/array.rb
origen-0.1.3 lib/origen/core_ext/array.rb
origen-0.1.2 lib/origen/core_ext/array.rb
origen-0.1.1 lib/origen/core_ext/array.rb
origen-0.1.0 lib/origen/core_ext/array.rb
origen-0.0.9 lib/origen/core_ext/array.rb
origen-0.0.8 lib/origen/core_ext/array.rb
origen-0.0.6 lib/origen/core_ext/array.rb
origen-0.0.5 lib/origen/core_ext/array.rb
origen-0.0.4 lib/origen/core_ext/array.rb
origen-0.0.3 lib/origen/core_ext/array.rb
origen-0.0.2 lib/origen/core_ext/array.rb