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 =
Characters stripped during normalization (whitespace and hyphens); classes may override.
/[\s-]/
Instance Method Summary collapse
-
#normalize! ⇒ self
Normalizes this identifier in place, updating #full_id.
-
#normalized ⇒ String
(also: #normalize)
Returns the canonical normalized form of this identifier.
-
#to_pretty_s ⇒ String?
Returns a human-readable formatted string, or nil if invalid.
- #to_s ⇒ String
- #to_str ⇒ String
Instance Method Details
#normalize! ⇒ self
Normalizes this identifier in place, updating #full_id.
56 57 58 59 |
# File 'lib/sec_id/concerns/normalizable.rb', line 56 def normalize! @full_id = normalized self end |
#normalized ⇒ String Also known as: normalize
Returns the canonical normalized form of this identifier.
42 43 44 45 |
# File 'lib/sec_id/concerns/normalizable.rb', line 42 def normalized validate! to_s end |
#to_pretty_s ⇒ String?
Returns a human-readable formatted string, or nil if invalid.
64 65 66 67 68 |
# File 'lib/sec_id/concerns/normalizable.rb', line 64 def to_pretty_s return nil unless valid? to_s end |
#to_s ⇒ String
71 72 73 |
# File 'lib/sec_id/concerns/normalizable.rb', line 71 def to_s identifier.to_s end |
#to_str ⇒ String
76 77 78 |
# File 'lib/sec_id/concerns/normalizable.rb', line 76 def to_str to_s end |