Class: UnicodeScriptDetector::SpoofDetector
- Inherits:
-
Object
- Object
- UnicodeScriptDetector::SpoofDetector
- Defined in:
- lib/unicode_script_detector/spoof_detector.rb
Defined Under Namespace
Classes: ConfusableChar, Detection, InvisibleChar
Constant Summary collapse
- SEVERITY_HIGH =
:high- SEVERITY_MEDIUM =
:medium- SEVERITY_LOW =
:low
Instance Method Summary collapse
-
#confusables ⇒ Object
Returns only confusable character detections.
-
#detections ⇒ Object
Returns all spoof detections found in the string.
-
#initialize(string) ⇒ SpoofDetector
constructor
A new instance of SpoofDetector.
-
#invisible_characters ⇒ Object
Returns only invisible character detections.
-
#mixed_scripts ⇒ Object
Returns only mixed script detections.
-
#spoofed? ⇒ Boolean
Returns true if any spoofing is detected.
Constructor Details
#initialize(string) ⇒ SpoofDetector
Returns a new instance of SpoofDetector.
11 12 13 14 |
# File 'lib/unicode_script_detector/spoof_detector.rb', line 11 def initialize(string) @string = string.to_s @detections = nil end |
Instance Method Details
#confusables ⇒ Object
Returns only confusable character detections
32 33 34 |
# File 'lib/unicode_script_detector/spoof_detector.rb', line 32 def confusables detections.select { |d| d.type == :confusable } end |
#detections ⇒ Object
Returns all spoof detections found in the string
17 18 19 20 21 22 23 24 |
# File 'lib/unicode_script_detector/spoof_detector.rb', line 17 def detections @detections ||= [ detect_confusables, detect_invisible_characters, detect_directional_overrides, detect_mixed_scripts ].compact end |
#invisible_characters ⇒ Object
Returns only invisible character detections
37 38 39 |
# File 'lib/unicode_script_detector/spoof_detector.rb', line 37 def invisible_characters detections.select { |d| d.type == :invisible } end |
#mixed_scripts ⇒ Object
Returns only mixed script detections
42 43 44 |
# File 'lib/unicode_script_detector/spoof_detector.rb', line 42 def mixed_scripts detections.select { |d| d.type == :mixed_scripts } end |
#spoofed? ⇒ Boolean
Returns true if any spoofing is detected
27 28 29 |
# File 'lib/unicode_script_detector/spoof_detector.rb', line 27 def spoofed? detections.any? end |