Class: Uzi::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/uzi-timer.rb,
lib/uzi-timer/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(duration) ⇒ Timer

Returns a new instance of Timer.



5
6
7
8
# File 'lib/uzi-timer.rb', line 5

def initialize(duration)
  @duration = duration
  reset
end

Instance Attribute Details

#alarmObject

Returns the value of attribute alarm.



3
4
5
# File 'lib/uzi-timer.rb', line 3

def alarm
  @alarm
end

#durationObject

Returns the value of attribute duration.



3
4
5
# File 'lib/uzi-timer.rb', line 3

def duration
  @duration
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/uzi-timer.rb', line 3

def time
  @time
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


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

def done?
  @alarm
end

#resetObject



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

def reset
  @time = 0
  @alarm = false
end

#update(delta) ⇒ Object



10
11
12
13
# File 'lib/uzi-timer.rb', line 10

def update(delta)
  @time += delta
  @alarm = true if @time > @duration
end