Class: LockstepSdk::StateModel
- Inherits:
-
Object
- Object
- LockstepSdk::StateModel
- Defined in:
- lib/lockstep_sdk/models/state_model.rb
Overview
State model for ISO-3166-2
Instance Attribute Summary collapse
-
#aliases ⇒ String
A different name for a state.
-
#alpha2 ⇒ String
2 letter alphabetic code for the given state.
-
#name ⇒ String
Name of the state.
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ object
This object as a JSON key-value structure.
-
#initialize(params = {}) ⇒ StateModel
constructor
Initialize the StateModel using the provided prototype.
-
#to_json(*options) ⇒ String
This object converted to a JSON string.
Constructor Details
#initialize(params = {}) ⇒ StateModel
Initialize the StateModel using the provided prototype
28 29 30 31 32 |
# File 'lib/lockstep_sdk/models/state_model.rb', line 28 def initialize(params = {}) @name = params.dig(:name) @alpha2 = params.dig(:alpha2) @aliases = params.dig(:aliases) end |
Instance Attribute Details
#aliases ⇒ String
Returns A different name for a state.
44 45 46 |
# File 'lib/lockstep_sdk/models/state_model.rb', line 44 def aliases @aliases end |
#alpha2 ⇒ String
Returns 2 letter alphabetic code for the given state.
40 41 42 |
# File 'lib/lockstep_sdk/models/state_model.rb', line 40 def alpha2 @alpha2 end |
#name ⇒ String
Returns Name of the state.
36 37 38 |
# File 'lib/lockstep_sdk/models/state_model.rb', line 36 def name @name end |
Instance Method Details
#as_json(options = {}) ⇒ object
Returns This object as a JSON key-value structure.
48 49 50 51 52 53 54 |
# File 'lib/lockstep_sdk/models/state_model.rb', line 48 def as_json(={}) { 'name' => @name, 'alpha2' => @alpha2, 'aliases' => @aliases, } end |
#to_json(*options) ⇒ String
Returns This object converted to a JSON string.
58 59 60 |
# File 'lib/lockstep_sdk/models/state_model.rb', line 58 def to_json(*) "[#{as_json(*).to_json(*)}]" end |