Class: Asdawqw::Location
- Defined in:
- lib/asdawqw/models/location.rb
Overview
Location Model.
Instance Attribute Summary collapse
-
#city ⇒ String
City of property.
-
#country ⇒ String
Country of property.
-
#postal_code ⇒ String
Postal code of property (Zip code).
-
#region ⇒ String
State (Region) of PM.
-
#street ⇒ String
Street of property.
-
#zip_code9 ⇒ String
Set only for US properties (format should be zip5-xxxx).
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.
Instance Method Summary collapse
-
#initialize(postal_code = nil, country = nil, region = nil, city = nil, street = nil, zip_code9 = nil) ⇒ Location
constructor
A new instance of Location.
Methods inherited from BaseModel
Constructor Details
#initialize(postal_code = nil, country = nil, region = nil, city = nil, street = nil, zip_code9 = nil) ⇒ Location
Returns a new instance of Location.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/asdawqw/models/location.rb', line 45 def initialize(postal_code = nil, country = nil, region = nil, city = nil, street = nil, zip_code9 = nil) @postal_code = postal_code @country = country @region = region @city = city @street = street @zip_code9 = zip_code9 end |
Instance Attribute Details
#city ⇒ String
City of property
23 24 25 |
# File 'lib/asdawqw/models/location.rb', line 23 def city @city end |
#country ⇒ String
Country of property. Require 2 letter ISO code
15 16 17 |
# File 'lib/asdawqw/models/location.rb', line 15 def country @country end |
#postal_code ⇒ String
Postal code of property (Zip code)
11 12 13 |
# File 'lib/asdawqw/models/location.rb', line 11 def postal_code @postal_code end |
#region ⇒ String
State (Region) of PM. Required for US properties.
19 20 21 |
# File 'lib/asdawqw/models/location.rb', line 19 def region @region end |
#street ⇒ String
Street of property
27 28 29 |
# File 'lib/asdawqw/models/location.rb', line 27 def street @street end |
#zip_code9 ⇒ String
Set only for US properties (format should be zip5-xxxx)
31 32 33 |
# File 'lib/asdawqw/models/location.rb', line 31 def zip_code9 @zip_code9 end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/asdawqw/models/location.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. postal_code = hash['postalCode'] country = hash['country'] region = hash['region'] city = hash['city'] street = hash['street'] zip_code9 = hash['zipCode9'] # Create object from extracted values. Location.new(postal_code, country, region, city, street, zip_code9) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/asdawqw/models/location.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['postal_code'] = 'postalCode' @_hash['country'] = 'country' @_hash['region'] = 'region' @_hash['city'] = 'city' @_hash['street'] = 'street' @_hash['zip_code9'] = 'zipCode9' @_hash end |