Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/unitmanager/utils.rb
Overview
Extension to standard Array class. Added functionality to compare array content regardless element order.
Instance Method Summary collapse
Instance Method Details
#contains?(other_array) ⇒ Boolean
48 49 50 51 52 53 54 55 |
# File 'lib/unitmanager/utils.rb', line 48 def contains?(other_array) copy = dup other_array.each {|item| return false unless i = copy.index(item) copy[i] = nil } true end |
#same?(other_array) ⇒ Boolean
57 58 59 60 |
# File 'lib/unitmanager/utils.rb', line 57 def same?(other_array) length == other_array.length && contains?(other_array) end |