Module: Jumbotron::TeamKey

Defined in:
lib/jumbotron/team_key.rb

Overview

Immutable semantic public team identity helper. Derives a kebab-case slug once at assignment; callers must not re-run on rename.

Constant Summary collapse

FORMAT =
/\A[a-z0-9]+(?:-[a-z0-9]+)*\z/

Class Method Summary collapse

Class Method Details

.normalize(name) ⇒ Object



11
12
13
14
15
16
# File 'lib/jumbotron/team_key.rb', line 11

def normalize(name)
  slug = name.to_s.unicode_normalize(:nfc).downcase
  slug = slug.gsub(/[^a-z0-9]+/, "-").gsub(/\A-+|-+\z/, "")
  slug = "team" if slug.blank?
  slug
end

.valid_format?(key) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/jumbotron/team_key.rb', line 18

def valid_format?(key)
  key.to_s.match?(FORMAT)
end