Class: Rclrb::Time
- Inherits:
-
Object
- Object
- Rclrb::Time
- Defined in:
- lib/rclrb/time.rb
Overview
Represent time.
Class Method Summary collapse
-
.from_sec(sec) ⇒ Object
Create a time objects from seconds.
-
.from_sec_nsec(sec, nsec) ⇒ Object
Create a time objects from seconds and nanoseconds.
Instance Method Summary collapse
-
#initialize(time = 0) ⇒ Time
constructor
Initialise time,
time
is given in seconds. -
#to_sec ⇒ Object
Return the time in seconds.
-
#to_sec_nsec ⇒ Object
Return the time in second and nanoseconds (as integers).
Constructor Details
#initialize(time = 0) ⇒ Time
Initialise time, time
is given in seconds
7 8 9 |
# File 'lib/rclrb/time.rb', line 7 def initialize time = 0 @time_sec = time end |
Class Method Details
Instance Method Details
#to_sec ⇒ Object
Return the time in seconds
22 23 24 |
# File 'lib/rclrb/time.rb', line 22 def to_sec return @time_sec end |
#to_sec_nsec ⇒ Object
Return the time in second and nanoseconds (as integers)
27 28 29 30 |
# File 'lib/rclrb/time.rb', line 27 def to_sec_nsec si = @time_sec.to_i return si, ((@time_sec - si) * 1e9).to_i end |