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
- .included(base) ⇒ Object private
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) ⇒ 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.
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.
55 56 57 58 |
# File 'lib/sec_id/concerns/normalizable.rb', line 55 def normalize! @full_id = normalized self end |
#normalized ⇒ String Also known as: normalize
Returns the canonical normalized form of this identifier.
41 42 43 44 |
# File 'lib/sec_id/concerns/normalizable.rb', line 41 def normalized validate! to_s end |
#to_pretty_s ⇒ String?
Returns a human-readable formatted string, or nil if invalid.
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_s ⇒ String
70 71 72 |
# File 'lib/sec_id/concerns/normalizable.rb', line 70 def to_s identifier.to_s end |
#to_str ⇒ String
75 76 77 |
# File 'lib/sec_id/concerns/normalizable.rb', line 75 def to_str to_s end |