Class: Period
- Inherits:
-
Object
- Object
- Period
- Defined in:
- lib/timetrackr/period.rb
Instance Attribute Summary collapse
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
- #current? ⇒ Boolean
-
#initialize(task, start, stop = nil, notes = '') ⇒ Period
constructor
A new instance of Period.
- #length ⇒ Object
Constructor Details
#initialize(task, start, stop = nil, notes = '') ⇒ Period
Returns a new instance of Period.
5 6 7 8 9 10 |
# File 'lib/timetrackr/period.rb', line 5 def initialize(task, start, stop=nil, notes='') @task = task @start = start @stop = stop @notes = notes end |
Instance Attribute Details
#notes ⇒ Object
Returns the value of attribute notes.
3 4 5 |
# File 'lib/timetrackr/period.rb', line 3 def notes @notes end |
#start ⇒ Object
Returns the value of attribute start.
3 4 5 |
# File 'lib/timetrackr/period.rb', line 3 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
3 4 5 |
# File 'lib/timetrackr/period.rb', line 3 def stop @stop end |
#task ⇒ Object
Returns the value of attribute task.
3 4 5 |
# File 'lib/timetrackr/period.rb', line 3 def task @task end |
Instance Method Details
#current? ⇒ Boolean
26 27 28 |
# File 'lib/timetrackr/period.rb', line 26 def current? self.stop.nil? end |
#length ⇒ Object
21 22 23 24 |
# File 'lib/timetrackr/period.rb', line 21 def length stop = self.stop || Time.now stop - self.start end |