Class: Array

Inherits:
Object show all
Defined in:
lib/ab_admin/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#contain?(other) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ab_admin/core_ext/array.rb', line 20

def contain?(other)
  (other - self).empty?
end

#deep_merge_hashesObject



2
3
4
5
6
7
# File 'lib/ab_admin/core_ext/array.rb', line 2

def deep_merge_hashes
  self.inject({}) do |res, h|
    raise Exception.new("Not a hash #{h}") unless h.is_a?(Hash)
    h.deep_merge(res)
  end
end

#intersect?(other) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ab_admin/core_ext/array.rb', line 24

def intersect?(other)
  !(self & other).empty?
end

#meanObject



9
10
11
12
# File 'lib/ab_admin/core_ext/array.rb', line 9

def mean
  return 0 if size == 0
  inject(:+) / size
end

#without!(*values) ⇒ Object



14
15
16
17
18
# File 'lib/ab_admin/core_ext/array.rb', line 14

def without!(*values)
  ActiveSupport::Deprecation.warn('Array#without! is deprecated without replacement')
  values.flatten.each { |value| self.delete(value) }
  self
end