Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/unitmanager/simple_unit.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
4 5 6 7 8 9 10 11 |
# File 'lib/unitmanager/simple_unit.rb', line 4 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
13 14 15 16 |
# File 'lib/unitmanager/simple_unit.rb', line 13 def same?(other_array) length == other_array.length && contains?(other_array) end |