Class: UnderOs::Timer::Duration

Inherits:
Object
  • Object
show all
Defined in:
lib/under_os/timer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#secondsObject (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(options={}, &block)
  UnderOs::Timer.in self, options={}, &block
end

#repeat(options = {}, &block) ⇒ Object



61
62
63
# File 'lib/under_os/timer.rb', line 61

def repeat(options={}, &block)
  UnderOs::Timer.every self, options={}, &block
end

#to_fObject



41
42
43
# File 'lib/under_os/timer.rb', line 41

def to_f
  @seconds
end

#to_iObject



45
46
47
# File 'lib/under_os/timer.rb', line 45

def to_i
  to_f.to_i
end

#to_sObject



49
50
51
# File 'lib/under_os/timer.rb', line 49

def to_s
  "#{to_f} seconds"
end