Class: Rex::Proto::NTP::Header::NTPShort

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/rex/proto/ntp/header.rb

Instance Method Summary collapse

Instance Method Details

#getObject



25
26
27
# File 'lib/rex/proto/ntp/header.rb', line 25

def get
  BigDecimal(seconds.value) + (BigDecimal(fraction.value) / BigDecimal(2**16))
end

#set(value) ⇒ Object



18
19
20
21
22
23
# File 'lib/rex/proto/ntp/header.rb', line 18

def set(value)
  value = value.to_d
  seconds = value.floor
  self.seconds = seconds
  self.fraction = ((value - seconds) * BigDecimal(2**16)).round
end