Class: Promptmenot::Patterns::Base
- Inherits:
-
Object
- Object
- Promptmenot::Patterns::Base
show all
- Defined in:
- lib/promptmenot/patterns/base.rb
Class Method Summary
collapse
Class Method Details
.category_name ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/promptmenot/patterns/base.rb', line 26
def category_name
name.split("::").last
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.downcase
.to_sym
end
|
.inherited(subclass) ⇒ Object
7
8
9
10
|
# File 'lib/promptmenot/patterns/base.rb', line 7
def inherited(subclass)
super
subclass.instance_variable_set(:@patterns, [])
end
|
.patterns ⇒ Object
12
13
14
|
# File 'lib/promptmenot/patterns/base.rb', line 12
def patterns
@patterns ||= []
end
|
.register(name:, regex:, sensitivity: :medium, confidence: :medium) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/promptmenot/patterns/base.rb', line 16
def register(name:, regex:, sensitivity: :medium, confidence: :medium)
patterns << Pattern.new(
name: name,
category: category_name,
regex: regex,
sensitivity: sensitivity,
confidence: confidence
)
end
|