Class: Period

Inherits:
Object
  • Object
show all
Defined in:
lib/timetrackr/period.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#notesObject

Returns the value of attribute notes.



3
4
5
# File 'lib/timetrackr/period.rb', line 3

def notes
  @notes
end

#startObject

Returns the value of attribute start.



3
4
5
# File 'lib/timetrackr/period.rb', line 3

def start
  @start
end

#stopObject

Returns the value of attribute stop.



3
4
5
# File 'lib/timetrackr/period.rb', line 3

def stop
  @stop
end

#taskObject

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/timetrackr/period.rb', line 26

def current?
  self.stop.nil?
end

#lengthObject



21
22
23
24
# File 'lib/timetrackr/period.rb', line 21

def length
  stop = self.stop || Time.now
  stop - self.start
end