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


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

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.


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

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.


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

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.


20
21
22
# File 'lib/fear/extractor/matcher/and.rb', line 20

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.


16
17
18
# File 'lib/fear/extractor/matcher/and.rb', line 16

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.


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

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