Class: CDEKApiClient::Entities::Location
- Inherits:
-
Object
- Object
- CDEKApiClient::Entities::Location
- Includes:
- Validatable
- Defined in:
- lib/cdek_api_client/entities/location.rb
Overview
Represents a location in the CDEK API. Each location has attributes such as code, city, and address.
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#code ⇒ Object
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(code:, city: nil, address: nil) ⇒ Location
constructor
Initializes a new Location object.
-
#to_json(*_args) ⇒ String
Converts the Location object to a JSON representation.
Methods included from Validatable
Constructor Details
#initialize(code:, city: nil, address: nil) ⇒ Location
Initializes a new Location object.
22 23 24 25 26 27 |
# File 'lib/cdek_api_client/entities/location.rb', line 22 def initialize(code:, city: nil, address: nil) @code = code @city = city @address = address validate! end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
10 11 12 |
# File 'lib/cdek_api_client/entities/location.rb', line 10 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
10 11 12 |
# File 'lib/cdek_api_client/entities/location.rb', line 10 def city @city end |
#code ⇒ Object
Returns the value of attribute code.
10 11 12 |
# File 'lib/cdek_api_client/entities/location.rb', line 10 def code @code end |
Instance Method Details
#to_json(*_args) ⇒ String
Converts the Location object to a JSON representation.
32 33 34 35 36 37 38 |
# File 'lib/cdek_api_client/entities/location.rb', line 32 def to_json(*_args) { code: @code, city: @city, address: @address }.to_json end |