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-]/
Class Method Summary collapse
-
.included(base) ⇒ void
private
Extends the including identifier class with the concern's class methods.
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
Class Method Details
.included(base) ⇒ void
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.
This method returns an undefined value.
Extends the including identifier class with the concern's class methods.
16 17 18 |
# File 'lib/sec_id/concerns/normalizable.rb', line 16 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#normalize! ⇒ self
Normalizes this identifier in place, updating #full_id.
60 61 62 63 |
# File 'lib/sec_id/concerns/normalizable.rb', line 60 def normalize! @full_id = normalized self end |
#normalized ⇒ String Also known as: normalize
Returns the canonical normalized form of this identifier.
46 47 48 49 |
# File 'lib/sec_id/concerns/normalizable.rb', line 46 def normalized validate! to_s end |
#to_pretty_s ⇒ String?
Returns a human-readable formatted string, or nil if invalid.
68 69 70 71 72 |
# File 'lib/sec_id/concerns/normalizable.rb', line 68 def to_pretty_s return nil unless valid? to_s end |
#to_s ⇒ String
75 76 77 |
# File 'lib/sec_id/concerns/normalizable.rb', line 75 def to_s identifier.to_s end |
#to_str ⇒ String
80 81 82 |
# File 'lib/sec_id/concerns/normalizable.rb', line 80 def to_str to_s end |