Class: Overnight::OvernightService
- Inherits:
-
Object
- Object
- Overnight::OvernightService
- Defined in:
- lib/overnight/overnight_service.rb
Constant Summary collapse
- @@timers =
{}
Class Method Summary collapse
-
.get_timer(timer_name) ⇒ Object
get a single timer by name.
-
.start_timer(timer_name = nil) ⇒ Object
start a timer with a name if a name is not selected, then a random one will be assigned.
-
.stop_timer(timer) ⇒ Object
stops a timer with either the actual timer or the name just in case there wasnt a name passed when the timer was started.
-
.timers ⇒ Object
get all of the timers.
Class Method Details
.get_timer(timer_name) ⇒ Object
get a single timer by name
25 26 27 |
# File 'lib/overnight/overnight_service.rb', line 25 def self.get_timer(timer_name) return @@timers[timer_name] end |
.start_timer(timer_name = nil) ⇒ Object
start a timer with a name if a name is not selected, then a random one will be assigned
7 8 9 10 11 |
# File 'lib/overnight/overnight_service.rb', line 7 def self.start_timer(timer_name = nil) timer_name ||= self.random_timer_name @@timers[timer_name] = Timer.new.start return @@timers[timer_name] end |
.stop_timer(timer) ⇒ Object
stops a timer with either the actual timer or the name just in case there wasnt a name passed when the timer was started
15 16 17 |
# File 'lib/overnight/overnight_service.rb', line 15 def self.stop_timer(timer) (@@timers[timer] || @@timers.values.select{|e| e == timer}.first).stop end |
.timers ⇒ Object
get all of the timers
20 21 22 |
# File 'lib/overnight/overnight_service.rb', line 20 def self.timers return @@timers end |