class Fear::Extractor::ExtractorMatcher
Match and extract pattern using registered extractor objects E.g. +Some(a : Integer)+ @see Extractor.register_extractor
Attributes
extractor[R]
Public Class Methods
new(*)
click to toggle source
@!attribute name
@return [Types::Strict::String]
@!attribute arguments_matcher
@return [ArrayMatcher | EmptyListMatcher]
Calls superclass method
# File lib/fear/extractor/extractor_matcher.rb, line 15 def initialize(*) super @extractor = Extractor.find_extractor(name) end
Public Instance Methods
call_or_else(arg) { |arg| ... }
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
Calls superclass method
# 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