Class: UspsApi::TrackingCurrentLocation
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::TrackingCurrentLocation
- Defined in:
- lib/usps_api/models/tracking_current_location.rb
Overview
Current location details for the tracking event.
Instance Attribute Summary collapse
-
#current_date_time ⇒ DateTime
Timestamp of the current location.
-
#latitude ⇒ Float
Latitude of the current location.
-
#longitude ⇒ Float
Longitude of the current 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(latitude:, longitude:, current_date_time:) ⇒ TrackingCurrentLocation
constructor
A new instance of TrackingCurrentLocation.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_current_date_time ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(latitude:, longitude:, current_date_time:) ⇒ TrackingCurrentLocation
Returns a new instance of TrackingCurrentLocation.
44 45 46 47 48 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 44 def initialize(latitude:, longitude:, current_date_time:) @latitude = latitude @longitude = longitude @current_date_time = current_date_time end |
Instance Attribute Details
#current_date_time ⇒ DateTime
Timestamp of the current location.
23 24 25 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 23 def current_date_time @current_date_time end |
#latitude ⇒ Float
Latitude of the current location.
15 16 17 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 15 def latitude @latitude end |
#longitude ⇒ Float
Longitude of the current location.
19 20 21 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 19 def longitude @longitude end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 51 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. latitude = hash.key?('latitude') ? hash['latitude'] : nil longitude = hash.key?('longitude') ? hash['longitude'] : nil current_date_time = if hash.key?('currentDateTime') (DateTimeHelper.from_rfc3339(hash['currentDateTime']) if hash['currentDateTime']) end # Create object from extracted values. TrackingCurrentLocation.new(latitude: latitude, longitude: longitude, current_date_time: current_date_time) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['latitude'] = 'latitude' @_hash['longitude'] = 'longitude' @_hash['current_date_time'] = 'currentDateTime' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 35 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
79 80 81 82 83 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 79 def inspect class_name = self.class.name.split('::').last "<#{class_name} latitude: #{@latitude.inspect}, longitude: #{@longitude.inspect},"\ " current_date_time: #{@current_date_time.inspect}>" end |
#to_custom_current_date_time ⇒ Object
67 68 69 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 67 def to_custom_current_date_time DateTimeHelper.to_rfc3339(current_date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
72 73 74 75 76 |
# File 'lib/usps_api/models/tracking_current_location.rb', line 72 def to_s class_name = self.class.name.split('::').last "<#{class_name} latitude: #{@latitude}, longitude: #{@longitude}, current_date_time:"\ " #{@current_date_time}>" end |