Class: Timert::Timer
- Inherits:
-
Object
- Object
- Timert::Timer
- Defined in:
- lib/timert/timer.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#today ⇒ Object
readonly
Returns the value of attribute today.
Instance Method Summary collapse
- #add_task(task) ⇒ Object
-
#initialize(today) ⇒ Timer
constructor
A new instance of Timer.
- #start(time = nil) ⇒ Object
- #stop(time = nil) ⇒ Object
Constructor Details
#initialize(today) ⇒ Timer
Returns a new instance of Timer.
5 6 7 |
# File 'lib/timert/timer.rb', line 5 def initialize(today) @today = today end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/timert/timer.rb', line 3 def path @path end |
#today ⇒ Object (readonly)
Returns the value of attribute today.
3 4 5 |
# File 'lib/timert/timer.rb', line 3 def today @today end |
Instance Method Details
#add_task(task) ⇒ Object
25 26 27 |
# File 'lib/timert/timer.rb', line 25 def add_task(task) today.add_task(task) end |
#start(time = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/timert/timer.rb', line 9 def start(time = nil) if !on? started = true today.add_start(time || now) end {time: today.last_start, started: started} end |
#stop(time = nil) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/timert/timer.rb', line 17 def stop(time = nil) if on? stopped = true today.add_stop(time || now) end {time: today.last_stop, stopped: stopped} end |