class DeepClassCompare::ArrayMatcher
Public Class Methods
new(klass = Array)
click to toggle source
Calls superclass method
# File lib/deep_class_compare/array_matcher.rb, line 4 def initialize(klass = Array) super(klass) end
Public Instance Methods
build_chain(*comparable)
click to toggle source
# 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)
click to toggle source
Calls superclass method
# File lib/deep_class_compare/array_matcher.rb, line 8 def match?(array) super && compare_array_with_chain(array) end
of(*comparable)
click to toggle source
# File lib/deep_class_compare/array_matcher.rb, line 12 def of(*comparable) dup.tap do |matcher| matcher.build_chain(*comparable) end end
Private Instance Methods
compare_array_with_chain(array)
click to toggle source
# File lib/deep_class_compare/array_matcher.rb, line 28 def compare_array_with_chain(array) array.all? do |value| compare_chain(value, @chain) end end