Class: TomatoPaste::Timer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(duration) ⇒ Timer

Returns a new instance of Timer.



8
9
10
11
12
13
# File 'lib/tomato_paste/timer.rb', line 8

def initialize(duration)
  @duration = duration
  @current = 0
  @state = :idle
  @interval_duration = 1
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



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

def current
  @current
end

#durationObject (readonly)

Returns the value of attribute duration.



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

def duration
  @duration
end

#interval_duration=(value) ⇒ Object (writeonly)

exposed for testing purposes



6
7
8
# File 'lib/tomato_paste/timer.rb', line 6

def interval_duration=(value)
  @interval_duration = value
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/tomato_paste/timer.rb', line 20

def done?
  @state == :done
end

#startObject



15
16
17
18
# File 'lib/tomato_paste/timer.rb', line 15

def start
  @state = :running
  time_becomes_a_loop
end