Module: SecID::Normalizable

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

Overview

Provides normalization methods for identifier types.

Including classes may override SEPARATORS (default ‘/[\s-]/`) and #normalized.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

SEPARATORS =
/[\s-]/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



11
12
13
# File 'lib/sec_id/concerns/normalizable.rb', line 11

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#normalize!self

Normalizes this identifier in place, updating #full_id.

Returns:

Raises:



55
56
57
58
# File 'lib/sec_id/concerns/normalizable.rb', line 55

def normalize!
  @full_id = normalized
  self
end

#normalizedString Also known as: normalize

Returns the canonical normalized form of this identifier.

Returns:

Raises:



41
42
43
44
# File 'lib/sec_id/concerns/normalizable.rb', line 41

def normalized
  validate!
  to_s
end

#to_pretty_sString?

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

Returns:



63
64
65
66
67
# File 'lib/sec_id/concerns/normalizable.rb', line 63

def to_pretty_s
  return nil unless valid?

  to_s
end

#to_sString

Returns:



70
71
72
# File 'lib/sec_id/concerns/normalizable.rb', line 70

def to_s
  identifier.to_s
end

#to_strString

Returns:



75
76
77
# File 'lib/sec_id/concerns/normalizable.rb', line 75

def to_str
  to_s
end