Class: UspsApi::TrackingPositionalInfo

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/tracking_positional_info.rb

Overview

Positional information for the shipment.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#accuracyFloat

Accuracy of the coordinates in meters.

Returns:

  • (Float)


26
27
28
# File 'lib/usps_api/models/tracking_positional_info.rb', line 26

def accuracy
  @accuracy
end

#distanceFloat

Distance traveled in kilometers.

Returns:

  • (Float)


18
19
20
# File 'lib/usps_api/models/tracking_positional_info.rb', line 18

def distance
  @distance
end

#ping_intervalInteger

Interval in milliseconds between location pings.

Returns:

  • (Integer)


14
15
16
# File 'lib/usps_api/models/tracking_positional_info.rb', line 14

def ping_interval
  @ping_interval
end

#speedFloat

Velocity of the device in meters per second.

Returns:

  • (Float)


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

.namesObject

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

.nullablesObject

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

.optionalsObject

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

#inspectObject

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_sObject

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