Class: Net::NTP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ntp/next.rb

Overview

Time information Response class Will be returned from Net::NTP::get

Instance Method Summary collapse

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

#latencyFloat

Latency

Returns:

  • (Float)


58
59
60
# File 'lib/net/ntp/next.rb', line 58

def latency
    @endTime-@startTime
end

#realDifferenceFloat

Time difference without latency

Returns:

  • (Float)


70
71
72
# File 'lib/net/ntp/next.rb', line 70

def realDifference
    timeDifference-(latency/2)
end

#timeDifferenceFloat

Difference between current time and real time

Returns:

  • (Float)


64
65
66
# File 'lib/net/ntp/next.rb', line 64

def timeDifference
    receive_timestamp-@startTime
end