Class: UnitedStates::State::Designation
- Inherits:
-
Object
- Object
- UnitedStates::State::Designation
- Defined in:
- lib/united_states/state/designation.rb
Overview
Represents the various way to designate a state (e.g. name, postal code).
Instance Attribute Summary collapse
-
#name ⇒ UnitedStates::State::Name
readonly
The state’s name.
-
#postal_code ⇒ UnitedStates::State::PostalCode
readonly
The state’s postal code.
Class Method Summary collapse
-
.from_hash(**hash) ⇒ UnitedStates::State::Designation
A Designation with attributes provided via hash.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Whether or not other’s name and postal code is equal to this Designation’s name and postal code.
-
#initialize(name:, postal_code:) ⇒ Designation
constructor
A new instance of Designation.
Constructor Details
#initialize(name:, postal_code:) ⇒ Designation
Returns a new instance of Designation.
44 45 46 47 |
# File 'lib/united_states/state/designation.rb', line 44 def initialize(name:, postal_code:) @name = UnitedStates::State::Name.new(name) @postal_code = UnitedStates::State::PostalCode.new(postal_code) end |
Instance Attribute Details
#name ⇒ UnitedStates::State::Name (readonly)
16 17 18 |
# File 'lib/united_states/state/designation.rb', line 16 def name @name end |
#postal_code ⇒ UnitedStates::State::PostalCode (readonly)
12 13 14 |
# File 'lib/united_states/state/designation.rb', line 12 def postal_code @postal_code end |
Class Method Details
.from_hash(**hash) ⇒ UnitedStates::State::Designation
Returns a Designation with attributes provided via hash.
30 31 32 |
# File 'lib/united_states/state/designation.rb', line 30 def self.from_hash(**hash) new(name: hash[:name], postal_code: hash[:postal_code]) end |
Instance Method Details
#==(other) ⇒ Boolean
53 54 55 56 |
# File 'lib/united_states/state/designation.rb', line 53 def ==(other) other.name == name && other.postal_code == postal_code end |