Class: Timer

Inherits:
Text show all
Defined in:
lib/timer.rb

Instance Attribute Summary collapse

Attributes inherited from Text

#color, #font, #horizontal, #vertical, #window

Instance Method Summary collapse

Methods inherited from Text

#draw, #horizon, #vert

Constructor Details

#initialize(window, max, font) ⇒ Timer

Returns a new instance of Timer.



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

def initialize window, max, font
  super window, max, font, :top, :right
  self.max = max
  self.reset
end

Instance Attribute Details

#maxObject

Returns the value of attribute max.



2
3
4
# File 'lib/timer.rb', line 2

def max
  @max
end

#startObject

Returns the value of attribute start.



2
3
4
# File 'lib/timer.rb', line 2

def start
  @start
end

Instance Method Details

#resetObject



13
14
15
# File 'lib/timer.rb', line 13

def reset
  self.start = Time.now
end

#valueObject



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

def value
  max - (Time.now - self.start).to_i
end