Class: Bellbro::Timer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit = nil) ⇒ Timer

Returns a new instance of Timer.



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

def initialize(limit=nil)
  @limit ||= 1.hour
  @started = Time.current
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



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

def limit
  @limit
end

#startedObject (readonly)

Returns the value of attribute started.



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

def started
  @started
end

Instance Method Details

#timed_out?Boolean

Returns:

  • (Boolean)


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

def timed_out?
  Time.current - started > limit
end