Class: UnderOs::Timer::Duration
Instance Attribute Summary collapse
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
Instance Method Summary collapse
- #==(duration) ⇒ Object
-
#initialize(seconds) ⇒ Duration
constructor
A new instance of Duration.
- #later(options = {}, &block) ⇒ Object
- #repeat(options = {}, &block) ⇒ Object
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(seconds) ⇒ Duration
Returns a new instance of Duration.
37 38 39 |
# File 'lib/under_os/timer.rb', line 37 def initialize(seconds) @seconds = seconds.to_f end |
Instance Attribute Details
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds.
35 36 37 |
# File 'lib/under_os/timer.rb', line 35 def seconds @seconds end |
Instance Method Details
#==(duration) ⇒ Object
53 54 55 |
# File 'lib/under_os/timer.rb', line 53 def ==(duration) duration.is_a?(UnderOs::Timer::Duration) && duration.seconds == @seconds end |
#later(options = {}, &block) ⇒ Object
57 58 59 |
# File 'lib/under_os/timer.rb', line 57 def later(={}, &block) UnderOs::Timer.in self, ={}, &block end |
#repeat(options = {}, &block) ⇒ Object
61 62 63 |
# File 'lib/under_os/timer.rb', line 61 def repeat(={}, &block) UnderOs::Timer.every self, ={}, &block end |
#to_f ⇒ Object
41 42 43 |
# File 'lib/under_os/timer.rb', line 41 def to_f @seconds end |
#to_i ⇒ Object
45 46 47 |
# File 'lib/under_os/timer.rb', line 45 def to_i to_f.to_i end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/under_os/timer.rb', line 49 def to_s "#{to_f} seconds" end |