Class: Fet::Ui::Timer

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

Overview

Determines and outputs the time spent playing

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#gameObject

Returns the value of attribute game.



9
10
11
# File 'lib/fet/ui/timer.rb', line 9

def game
  @game
end

#started_atObject

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_loopObject



24
25
26
# File 'lib/fet/ui/timer.rb', line 24

def handle_update_loop
  update_time_elapsed
end

#seconds_elapsedObject



28
29
30
# File 'lib/fet/ui/timer.rb', line 28

def seconds_elapsed
  current_time - start_time
end

#startObject



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