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.52.1 lib/origen/core_ext/array.rb
origen-0.52.0 lib/origen/core_ext/array.rb
origen-0.51.3 lib/origen/core_ext/array.rb
origen-0.51.2 lib/origen/core_ext/array.rb
origen-0.51.1 lib/origen/core_ext/array.rb
origen-0.51.0 lib/origen/core_ext/array.rb
origen-0.50.0 lib/origen/core_ext/array.rb
origen-0.44.0 lib/origen/core_ext/array.rb
origen-0.43.0 lib/origen/core_ext/array.rb
origen-0.42.2 lib/origen/core_ext/array.rb
origen-0.42.1 lib/origen/core_ext/array.rb
origen-0.42.0 lib/origen/core_ext/array.rb
origen-0.41.2 lib/origen/core_ext/array.rb
origen-0.41.1 lib/origen/core_ext/array.rb
origen-0.41.0 lib/origen/core_ext/array.rb
origen-0.40.2 lib/origen/core_ext/array.rb
origen-0.40.1 lib/origen/core_ext/array.rb
origen-0.40.0 lib/origen/core_ext/array.rb
origen-0.38.0 lib/origen/core_ext/array.rb
origen-0.37.0 lib/origen/core_ext/array.rb