Class: Fear::Extractor::Pattern Private

Inherits:
Object
  • Object
show all
Defined in:
lib/fear/extractor/pattern.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.

Parse pattern. Used within Fear[]

Constant Summary collapse

DEFAULT_PATTERN_CACHE_SIZE =

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

10_000

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Pattern

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 Pattern.



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

def initialize(pattern)
  @matcher = compile_pattern(pattern)
end

Class Attribute Details

.pattern_cacheObject (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.



11
12
13
# File 'lib/fear/extractor/pattern.rb', line 11

def pattern_cache
  @pattern_cache
end

Instance Method Details

#===(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
# File 'lib/fear/extractor/pattern.rb', line 35

def ===(other)
  matcher.defined_at?(other)
end

#and_then(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.



39
40
41
# File 'lib/fear/extractor/pattern.rb', line 39

def and_then(other)
  Fear::PartialFunction::Combined.new(matcher, other)
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.



43
44
45
# File 'lib/fear/extractor/pattern.rb', line 43

def failure_reason(other)
  matcher.failure_reason(other).get_or_else { 'It matches' }
end