Class: FFI::PCap::TimeVal
- Inherits:
-
Struct
- Object
- Struct
- FFI::PCap::TimeVal
- Includes:
- DRY::StructHelper
- Defined in:
- lib/ffi/pcap/time_val.rb
Instance Method Summary collapse
-
#initialize(timeval = nil) ⇒ TimeVal
constructor
Initializes the new TimeVal.
-
#time ⇒ Time
(also: #to_time)
Returns the time value as a ruby Time object.
-
#time=(new_time) ⇒ Time
Sets the time value from a ruby Time object.
Constructor Details
#initialize(timeval = nil) ⇒ TimeVal
Initializes the new FFI::PCap::TimeVal.
18 19 20 21 22 23 24 25 26 27 |
# 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 |
Instance Method Details
#time ⇒ Time Also known as: to_time
Returns the time value as a ruby Time object.
38 39 40 |
# File 'lib/ffi/pcap/time_val.rb', line 38 def time Time.at(self.tv_sec, self.tv_usec) end |
#time=(new_time) ⇒ Time
Sets the time value from a ruby Time object
53 54 55 56 57 58 |
# 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 |