class FFI::PCap::TimeVal
Public Class Methods
new(timeval=nil)
click to toggle source
Initializes the new {TimeVal}.
@param [Time, FFI::Pointer] timeval
A Time object or a pointer to another {TimeVal}.
Calls superclass method
# File lib/ffi/pcap/time_val.rb, line 18 def initialize(timeval=nil) case timeval when Time super() self.time = timeval when Pointer then super(timeval) else super() end end
Public Instance Methods
time()
click to toggle source
Returns the time value as a ruby Time object.
@return [Time]
A ruby time object derived from this TimeVal.
# File lib/ffi/pcap/time_val.rb, line 38 def time Time.at(self.tv_sec, self.tv_usec) end
Also aliased as: to_time
time=(new_time)
click to toggle source
Sets the time value from a ruby Time object
@param [Time] new_time
A ruby time object from which to set the time.
@return [Time]
Returns the same Time object supplied per convention.
# File lib/ffi/pcap/time_val.rb, line 53 def time=(new_time) self.tv_sec = new_time.tv_sec self.tv_usec = new_time.tv_usec return new_time end