Class: Fear::Extractor::ExtractorMatcher Private
- Defined in:
- lib/fear/extractor/extractor_matcher.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.
Match and extract pattern using registered extractor objects E.g. Some(a : Integer)
Constant Summary
Constants inherited from Matcher
Matcher::EMPTY_ARRAY, Matcher::EMPTY_HASH
Instance Attribute Summary collapse
Instance Method Summary collapse
- #call_or_else(arg) ⇒ Object private
- #defined_at?(other) ⇒ Boolean private
- #failure_reason(other) ⇒ Object private
-
#initialize ⇒ ExtractorMatcher
constructor
private
A new instance of ExtractorMatcher.
Methods inherited from Matcher
Constructor Details
#initialize ⇒ ExtractorMatcher
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 ExtractorMatcher.
15 16 17 18 |
# File 'lib/fear/extractor/extractor_matcher.rb', line 15 def initialize(*) super @extractor = Extractor.find_extractor(name) end |
Instance Attribute Details
#arguments_matcher ⇒ ArrayMatcher | EmptyListMatcher
15 16 17 18 |
# File 'lib/fear/extractor/extractor_matcher.rb', line 15 def initialize(*) super @extractor = Extractor.find_extractor(name) end |
#name ⇒ Types::Strict::String
15 16 17 18 |
# File 'lib/fear/extractor/extractor_matcher.rb', line 15 def initialize(*) super @extractor = Extractor.find_extractor(name) end |
Instance Method Details
#call_or_else(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.
29 30 31 32 33 |
# File 'lib/fear/extractor/extractor_matcher.rb', line 29 def call_or_else(arg) extractor.(arg) .map { |v| arguments_matcher.call_or_else(v) { yield arg } } .get_or_else { yield arg } end |
#defined_at?(other) ⇒ 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.
22 23 24 25 26 27 |
# File 'lib/fear/extractor/extractor_matcher.rb', line 22 def defined_at?(other) extractor .(other) .map { |v| arguments_matcher.defined_at?(v) } .get_or_else(false) end |
#failure_reason(other) ⇒ 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.
35 36 37 38 39 40 41 |
# File 'lib/fear/extractor/extractor_matcher.rb', line 35 def failure_reason(other) extractor.(other).match do |m| m.some(->(v) { arguments_matcher.defined_at?(v) }) { Fear.none } m.some { |v| arguments_matcher.failure_reason(v) } m.none { super } end end |