Class: DeepClassCompare::ArrayMatcher
- Includes:
- ContainerComparable
- Defined in:
- lib/deep_class_compare/array_matcher.rb
Instance Method Summary collapse
- #build_chain(*comparable) ⇒ Object
-
#initialize(klass = Array) ⇒ ArrayMatcher
constructor
A new instance of ArrayMatcher.
- #match?(array) ⇒ Boolean
- #of(*comparable) ⇒ Object
Methods inherited from Matcher
Constructor Details
#initialize(klass = Array) ⇒ ArrayMatcher
Returns a new instance of ArrayMatcher.
4 5 6 |
# File 'lib/deep_class_compare/array_matcher.rb', line 4 def initialize(klass = Array) super(klass) end |
Instance Method Details
#build_chain(*comparable) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/deep_class_compare/array_matcher.rb', line 18 def build_chain(*comparable) @chain = if @chain.nil? parse_comparable_to_chain(comparable.first) elsif @chain.is_a?(Matcher) @chain.of(*comparable) end raise_pattern_error! if @chain.nil? end |
#match?(array) ⇒ Boolean
8 9 10 |
# File 'lib/deep_class_compare/array_matcher.rb', line 8 def match?(array) super && compare_array_with_chain(array) end |
#of(*comparable) ⇒ Object
12 13 14 15 16 |
# File 'lib/deep_class_compare/array_matcher.rb', line 12 def of(*comparable) dup.tap do |matcher| matcher.build_chain(*comparable) end end |