Class: Net::NTP::Response
- Inherits:
-
Object
- Object
- Net::NTP::Response
- Defined in:
- lib/net/ntp/next.rb
Overview
Time information Response class
Will be returned from Net::NTP::get
Instance Method Summary collapse
-
#initialize(raw_data, startTime = 0, endTime = 0) ⇒ Response
constructor
A new instance of Response.
-
#latency ⇒ Float
Latency.
-
#realDifference ⇒ Float
Time difference without latency.
-
#timeDifference ⇒ Float
Difference between current time and real time.
Constructor Details
#initialize(raw_data, startTime = 0, endTime = 0) ⇒ Response
Returns a new instance of Response.
48 49 50 51 52 53 54 |
# File 'lib/net/ntp/next.rb', line 48 def initialize(raw_data, startTime=0, endTime=0) @raw_data = raw_data @client_time_receive = Time.new.to_i @packet_data_by_field = nil @startTime = startTime @endTime = endTime end |
Instance Method Details
#latency ⇒ Float
Latency
58 59 60 |
# File 'lib/net/ntp/next.rb', line 58 def latency @endTime-@startTime end |
#realDifference ⇒ Float
Time difference without latency
70 71 72 |
# File 'lib/net/ntp/next.rb', line 70 def realDifference timeDifference-(latency/2) end |
#timeDifference ⇒ Float
Difference between current time and real time
64 65 66 |
# File 'lib/net/ntp/next.rb', line 64 def timeDifference -@startTime end |