Module: SecID::Normalizable::ClassMethods

Defined in:
lib/sec_id/concerns/normalizable.rb

Overview

Class methods added when Normalizable is included.

Instance Method Summary collapse

Instance Method Details

#normalize(id) ⇒ String

Normalizes the identifier to its canonical format.

Parameters:

  • id (String, #to_s)

    the identifier to normalize

Returns:

  • (String)

    the normalized identifier

Raises:



22
23
24
25
# File 'lib/sec_id/concerns/normalizable.rb', line 22

def normalize(id)
  cleaned = id.to_s.strip.gsub(self::SEPARATORS, '')
  new(cleaned.upcase).normalized
end

#to_pretty_s(id) ⇒ String?

Returns a human-readable formatted string, or nil if invalid.

Parameters:

  • id (String, #to_s)

    the identifier to format

Returns:

  • (String, nil)


31
32
33
34
# File 'lib/sec_id/concerns/normalizable.rb', line 31

def to_pretty_s(id)
  cleaned = id.to_s.strip.gsub(self::SEPARATORS, '')
  new(cleaned.upcase).to_pretty_s
end