Class: Timer

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

Direct Known Subclasses

Timers::Break, Timers::Exercise

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, message = '') ⇒ Timer

Returns a new instance of Timer.



4
5
6
7
# File 'lib/tabata_timer/timer.rb', line 4

def initialize(time, message = '')
  @time = time
  @message = message
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



2
3
4
# File 'lib/tabata_timer/timer.rb', line 2

def time
  @time
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/tabata_timer/timer.rb', line 14

def ==(other)
  self.time == other.time
end

#startObject



9
10
11
12
# File 'lib/tabata_timer/timer.rb', line 9

def start
  `say #{@message}`
  sleep(@time)
end