Class: Uzi::Timer
- Inherits:
-
Object
- Object
- Uzi::Timer
- Defined in:
- lib/uzi-timer.rb,
lib/uzi-timer/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#alarm ⇒ Object
Returns the value of attribute alarm.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(duration) ⇒ Timer
constructor
A new instance of Timer.
- #reset ⇒ Object
- #update(delta) ⇒ Object
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
#alarm ⇒ Object
Returns the value of attribute alarm.
3 4 5 |
# File 'lib/uzi-timer.rb', line 3 def alarm @alarm end |
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/uzi-timer.rb', line 3 def duration @duration end |
#time ⇒ Object
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
20 21 22 |
# File 'lib/uzi-timer.rb', line 20 def done? @alarm end |
#reset ⇒ Object
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 |