Class: ShellEv::Address
- Defined in:
- lib/shell_ev/models/address.rb
Overview
Address of the Shell Recharge Location
Instance Attribute Summary collapse
-
#city ⇒ String
City name of the Shell Recharge Location.
-
#country ⇒ String
ISO 3166 Alpha-2 Country Code of the Shell Recharge Location.
-
#postal_code ⇒ String
Postal Code of the Shell Recharge Location.
-
#street_and_number ⇒ String
Street Name and Number of the Shell Recharge Location.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(street_and_number = SKIP, postal_code = SKIP, city = SKIP, country = SKIP) ⇒ Address
constructor
A new instance of Address.
Methods inherited from BaseModel
Constructor Details
#initialize(street_and_number = SKIP, postal_code = SKIP, city = SKIP, country = SKIP) ⇒ Address
Returns a new instance of Address.
53 54 55 56 57 58 59 |
# File 'lib/shell_ev/models/address.rb', line 53 def initialize(street_and_number = SKIP, postal_code = SKIP, city = SKIP, country = SKIP) @street_and_number = street_and_number unless street_and_number == SKIP @postal_code = postal_code unless postal_code == SKIP @city = city unless city == SKIP @country = country unless country == SKIP end |
Instance Attribute Details
#city ⇒ String
City name of the Shell Recharge Location
22 23 24 |
# File 'lib/shell_ev/models/address.rb', line 22 def city @city end |
#country ⇒ String
ISO 3166 Alpha-2 Country Code of the Shell Recharge Location
26 27 28 |
# File 'lib/shell_ev/models/address.rb', line 26 def country @country end |
#postal_code ⇒ String
Postal Code of the Shell Recharge Location
18 19 20 |
# File 'lib/shell_ev/models/address.rb', line 18 def postal_code @postal_code end |
#street_and_number ⇒ String
Street Name and Number of the Shell Recharge Location
14 15 16 |
# File 'lib/shell_ev/models/address.rb', line 14 def street_and_number @street_and_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/shell_ev/models/address.rb', line 62 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. street_and_number = hash.key?('streetAndNumber') ? hash['streetAndNumber'] : SKIP postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP city = hash.key?('city') ? hash['city'] : SKIP country = hash.key?('country') ? hash['country'] : SKIP # Create object from extracted values. Address.new(street_and_number, postal_code, city, country) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/shell_ev/models/address.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['street_and_number'] = 'streetAndNumber' @_hash['postal_code'] = 'postalCode' @_hash['city'] = 'city' @_hash['country'] = 'country' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/shell_ev/models/address.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 45 46 |
# File 'lib/shell_ev/models/address.rb', line 39 def self.optionals %w[ street_and_number postal_code city country ] end |