Class: Iriq::Recognizers::Uuid

Inherits:
Iriq::Recognizer show all
Defined in:
lib/iriq/recognizers/uuid.rb

Overview

RFC 4122 UUID. Shape-only — does not validate version/variant bits.

Constant Summary collapse

PATTERN =
/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/.freeze

Instance Method Summary collapse

Methods inherited from Iriq::Recognizer

ensemble

Instance Method Details

#try(segment) ⇒ Object



7
8
9
10
11
# File 'lib/iriq/recognizers/uuid.rb', line 7

def try(segment)
  return nil unless segment.size == 36 && segment.include?("-") && PATTERN.match?(segment)

  { type: :uuid, confidence: 1.0, specificity: Specificity::SEMANTIC }
end