Class: UspsApi::TrackingPositionalInfo
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::TrackingPositionalInfo
- Defined in:
- lib/usps_api/models/tracking_positional_info.rb
Overview
Positional information for the shipment.
Instance Attribute Summary collapse
-
#accuracy ⇒ Float
Accuracy of the coordinates in meters.
-
#distance ⇒ Float
Distance traveled in kilometers.
-
#ping_interval ⇒ Integer
Interval in milliseconds between location pings.
-
#speed ⇒ Float
Velocity of the device in meters per second.
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(ping_interval:, distance:, speed:, accuracy:) ⇒ TrackingPositionalInfo
constructor
A new instance of TrackingPositionalInfo.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(ping_interval:, distance:, speed:, accuracy:) ⇒ TrackingPositionalInfo
Returns a new instance of TrackingPositionalInfo.
51 52 53 54 55 56 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 51 def initialize(ping_interval:, distance:, speed:, accuracy:) @ping_interval = ping_interval @distance = distance @speed = speed @accuracy = accuracy end |
Instance Attribute Details
#accuracy ⇒ Float
Accuracy of the coordinates in meters.
26 27 28 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 26 def accuracy @accuracy end |
#distance ⇒ Float
Distance traveled in kilometers.
18 19 20 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 18 def distance @distance end |
#ping_interval ⇒ Integer
Interval in milliseconds between location pings.
14 15 16 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 14 def ping_interval @ping_interval end |
#speed ⇒ Float
Velocity of the device in meters per second.
22 23 24 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 22 def speed @speed end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 59 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. ping_interval = hash.key?('pingInterval') ? hash['pingInterval'] : nil distance = hash.key?('distance') ? hash['distance'] : nil speed = hash.key?('speed') ? hash['speed'] : nil accuracy = hash.key?('accuracy') ? hash['accuracy'] : nil # Create object from extracted values. TrackingPositionalInfo.new(ping_interval: ping_interval, distance: distance, speed: speed, accuracy: accuracy) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['ping_interval'] = 'pingInterval' @_hash['distance'] = 'distance' @_hash['speed'] = 'speed' @_hash['accuracy'] = 'accuracy' @_hash end |
.nullables ⇒ Object
An array for nullable fields
44 45 46 47 48 49 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 44 def self.nullables %w[ speed accuracy ] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 39 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
83 84 85 86 87 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 83 def inspect class_name = self.class.name.split('::').last "<#{class_name} ping_interval: #{@ping_interval.inspect}, distance: #{@distance.inspect},"\ " speed: #{@speed.inspect}, accuracy: #{@accuracy.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
76 77 78 79 80 |
# File 'lib/usps_api/models/tracking_positional_info.rb', line 76 def to_s class_name = self.class.name.split('::').last "<#{class_name} ping_interval: #{@ping_interval}, distance: #{@distance}, speed: #{@speed},"\ " accuracy: #{@accuracy}>" end |