Class: Fet::Ui::Timer
- Inherits:
-
Object
- Object
- Fet::Ui::Timer
- Defined in:
- lib/fet/ui/timer.rb
Overview
Determines and outputs the time spent playing
Instance Attribute Summary collapse
-
#game ⇒ Object
Returns the value of attribute game.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
Instance Method Summary collapse
- #handle_event_loop(event) ⇒ Object
- #handle_update_loop ⇒ Object
-
#initialize(game) ⇒ Timer
constructor
A new instance of Timer.
- #seconds_elapsed ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(game) ⇒ Timer
Returns a new instance of Timer.
11 12 13 |
# File 'lib/fet/ui/timer.rb', line 11 def initialize(game) self.game = game end |
Instance Attribute Details
#game ⇒ Object
Returns the value of attribute game.
9 10 11 |
# File 'lib/fet/ui/timer.rb', line 9 def game @game end |
#started_at ⇒ Object
Returns the value of attribute started_at.
9 10 11 |
# File 'lib/fet/ui/timer.rb', line 9 def started_at @started_at end |
Instance Method Details
#handle_event_loop(event) ⇒ Object
22 |
# File 'lib/fet/ui/timer.rb', line 22 def handle_event_loop(event); end |
#handle_update_loop ⇒ Object
24 25 26 |
# File 'lib/fet/ui/timer.rb', line 24 def handle_update_loop update_time_elapsed end |
#seconds_elapsed ⇒ Object
28 29 30 |
# File 'lib/fet/ui/timer.rb', line 28 def seconds_elapsed current_time - start_time end |
#start ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fet/ui/timer.rb', line 15 def start self.started_at ||= DateTime.now.new_offset(0) self.start_time ||= current_time self.text ||= generate_text text.text = time_elapsed end |