Sha256: f00ba60311a0f004f50d7df42fecbb48e56ba04614236e9a495e8eb56364cb79

Contents?: true

Size: 623 Bytes

Versions: 84

Compression:

Stored size: 623 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

  def include_hash?
    each { |e| return true if e.is_a? Hash }
    false
  end

  def include_hash_with_key?(key)
    each do |e|
      if e.is_a? Hash
        return e if e.key?(key)
      end
    end
    nil
  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
origen-0.60.7 lib/origen/core_ext/array.rb
origen-0.60.6 lib/origen/core_ext/array.rb
origen-0.60.5 lib/origen/core_ext/array.rb
origen-0.60.4 lib/origen/core_ext/array.rb
origen-0.60.3 lib/origen/core_ext/array.rb
origen-0.60.2 lib/origen/core_ext/array.rb
origen-0.60.1 lib/origen/core_ext/array.rb
origen-0.60.0 lib/origen/core_ext/array.rb
origen-0.59.8 lib/origen/core_ext/array.rb
origen-0.59.7 lib/origen/core_ext/array.rb
origen-0.59.6 lib/origen/core_ext/array.rb
origen-0.59.5 lib/origen/core_ext/array.rb
origen-0.59.4 lib/origen/core_ext/array.rb
origen-0.59.3 lib/origen/core_ext/array.rb
origen-0.59.2 lib/origen/core_ext/array.rb
origen-0.59.1 lib/origen/core_ext/array.rb
origen-0.59.0 lib/origen/core_ext/array.rb
origen-0.58.0 lib/origen/core_ext/array.rb
origen-0.57.2 lib/origen/core_ext/array.rb
origen-0.57.1 lib/origen/core_ext/array.rb