Class: ComparableArray
- Inherits:
-
Object
- Object
- ComparableArray
- Defined in:
- lib/rspec_rails_extensions/comparable_array.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
Instance Method Summary collapse
- #=~(other_array) ⇒ Object
-
#initialize(array) ⇒ ComparableArray
constructor
A new instance of ComparableArray.
- #inspect ⇒ Object
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(array) ⇒ ComparableArray
Returns a new instance of ComparableArray.
4 5 6 |
# File 'lib/rspec_rails_extensions/comparable_array.rb', line 4 def initialize array @array = array.dup end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rspec_rails_extensions/comparable_array.rb', line 16 def method_missing method, *args if array.respond_to?(method) array.send(method, *args) else super end end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
2 3 4 |
# File 'lib/rspec_rails_extensions/comparable_array.rb', line 2 def array @array end |
Instance Method Details
#=~(other_array) ⇒ Object
8 9 10 |
# File 'lib/rspec_rails_extensions/comparable_array.rb', line 8 def =~ other_array array.size == other_array.size && array.all? {|e| other_array.include?(e) } end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/rspec_rails_extensions/comparable_array.rb', line 12 def inspect array.inspect end |