Class: Fear::Extractor::Matcher::And Private

Inherits:
Fear::Extractor::Matcher show all
Defined in:
lib/fear/extractor/matcher/and.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Combine two matchers, so both should pass

Constant Summary

Constants inherited from Fear::Extractor::Matcher

EMPTY_ARRAY, EMPTY_HASH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Fear::Extractor::Matcher

#and, #call, #call_or_else

Constructor Details

#initialize(matcher1, matcher2) ⇒ And

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of And.



8
9
10
11
# File 'lib/fear/extractor/matcher/and.rb', line 8

def initialize(matcher1, matcher2)
  @matcher1 = matcher1
  @matcher2 = matcher2
end

Instance Attribute Details

#matcher1Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/fear/extractor/matcher/and.rb', line 12

def matcher1
  @matcher1
end

#matcher2Object (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/fear/extractor/matcher/and.rb', line 12

def matcher2
  @matcher2
end

Instance Method Details

#bindings(arg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/fear/extractor/matcher/and.rb', line 18

def bindings(arg)
  matcher1.bindings(arg).merge(matcher2.bindings(arg))
end

#defined_at?(arg) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


14
15
16
# File 'lib/fear/extractor/matcher/and.rb', line 14

def defined_at?(arg)
  matcher1.defined_at?(arg) && matcher2.defined_at?(arg)
end

#failure_reason(arg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fear/extractor/matcher/and.rb', line 22

def failure_reason(arg)
  if matcher1.defined_at?(arg)
    if matcher2.defined_at?(arg)
      Fear.none
    else
      matcher2.failure_reason(arg)
    end
  else
    matcher1.failure_reason(arg)
  end
end