Class: UnitedStates::State::PostalCode
- Inherits:
-
Object
- Object
- UnitedStates::State::PostalCode
- Defined in:
- lib/united_states/state/postal_code.rb
Overview
A U.S. State postal code.
Defined Under Namespace
Classes: StringTooLongError, StringTooShortError
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether or not other.to_s matches self.to_s.
- #initialize(string) ⇒ UnitedStates::State::PostalCode constructor
-
#lowercase ⇒ String
An all lowercase version of this PostalCode.
-
#to_s ⇒ String
An all uppercase version of this PostalCode.
-
#uppercase ⇒ String
An all uppercase version of this PostalCode.
Constructor Details
#initialize(string) ⇒ UnitedStates::State::PostalCode
36 37 38 39 40 41 |
# File 'lib/united_states/state/postal_code.rb', line 36 def initialize(string) string = string.to_s ensure_string_not_too_long(string) ensure_string_not_too_short(string) @string = string end |
Instance Method Details
#==(other) ⇒ Boolean
Returns whether or not other.to_s matches self.to_s.
46 47 48 |
# File 'lib/united_states/state/postal_code.rb', line 46 def ==(other) other.to_s == to_s end |
#lowercase ⇒ String
Returns an all lowercase version of this PostalCode.
52 53 54 |
# File 'lib/united_states/state/postal_code.rb', line 52 def lowercase @string.downcase end |
#to_s ⇒ String
Returns an all uppercase version of this PostalCode.
64 65 66 |
# File 'lib/united_states/state/postal_code.rb', line 64 def to_s uppercase end |
#uppercase ⇒ String
Returns an all uppercase version of this PostalCode.
58 59 60 |
# File 'lib/united_states/state/postal_code.rb', line 58 def uppercase @string.upcase end |