Class: Array
Instance Method Summary collapse
- #contain?(other) ⇒ Boolean
- #deep_merge_hashes ⇒ Object
- #intersect?(other) ⇒ Boolean
- #mean ⇒ Object
- #without!(*values) ⇒ Object
Instance Method Details
#contain?(other) ⇒ Boolean
20 21 22 |
# File 'lib/ab_admin/core_ext/array.rb', line 20 def contain?(other) (other - self).empty? end |
#deep_merge_hashes ⇒ Object
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
24 25 26 |
# File 'lib/ab_admin/core_ext/array.rb', line 24 def intersect?(other) !(self & other).empty? end |
#mean ⇒ Object
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 |