Class: Array
Instance Method Summary
collapse
Instance Method Details
10
11
12
|
# File 'lib/origen/core_ext/array.rb', line 10
def dups
(select { |e| rindex(e) != index(e) }).uniq
end
|
#dups? ⇒ Boolean
6
7
8
|
# File 'lib/origen/core_ext/array.rb', line 6
def dups?
find { |e| rindex(e) != index(e) } ? true : false
end
|
#dups_with_index ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/origen/core_ext/array.rb', line 14
def dups_with_index
return {} unless 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
|
2
3
4
|
# File 'lib/origen/core_ext/array.rb', line 2
def ids
map(&:id)
end
|
#include_hash? ⇒ Boolean
25
26
27
28
|
# File 'lib/origen/core_ext/array.rb', line 25
def include_hash?
each { |e| return true if e.is_a? Hash }
false
end
|
#include_hash_with_key?(key) ⇒ Boolean
30
31
32
33
34
35
36
37
|
# File 'lib/origen/core_ext/array.rb', line 30
def include_hash_with_key?(key)
each do |e|
if e.is_a? Hash
return e if e.key?(key)
end
end
nil
end
|