Class: Caper::TimeVal
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Caper::TimeVal
- Includes:
- FFI::DRY::StructHelper
- Defined in:
- lib/caper/time_val.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ TimeVal
constructor
A new instance of TimeVal.
-
#time ⇒ Time
(also: #to_time)
Returns the time value as a ruby Time object.
-
#time=(t) ⇒ Time
Sets the time value from a ruby Time object.
Constructor Details
#initialize(*args) ⇒ TimeVal
Returns a new instance of TimeVal.
10 11 12 13 14 15 16 |
# File 'lib/caper/time_val.rb', line 10 def initialize(*args) if args.size == 1 and (t=args[0]).kind_of?(Time) self.time = t else super(*args) end end |
Instance Method Details
#time ⇒ Time Also known as: to_time
Returns the time value as a ruby Time object.
25 26 27 |
# File 'lib/caper/time_val.rb', line 25 def time Time.at(self.tv_sec, self.tv_usec) end |
#time=(t) ⇒ Time
Sets the time value from a ruby Time object
39 40 41 42 43 |
# File 'lib/caper/time_val.rb', line 39 def time=(t) self.tv_sec = t.tv_sec self.tv_usec = t.tv_usec return t end |