Class: Workit::Model::Task

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/workit/model/task.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.can_finish?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/workit/model/task.rb', line 36

def self.can_finish?
  self.all(:state.not => 'finished').count == 1
end

.can_start?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/workit/model/task.rb', line 32

def self.can_start?
  self.all(:state => 'started').empty?
end

.currentObject



40
41
42
# File 'lib/workit/model/task.rb', line 40

def self.current
  self.first(:state.not => 'finished')
end

Instance Method Details

#destroy_spansObject



48
49
50
# File 'lib/workit/model/task.rb', line 48

def destroy_spans
  self.spans.all.map(&:destroy)
end

#durationObject



44
45
46
# File 'lib/workit/model/task.rb', line 44

def duration
  self.spans.map(&:duration).inject :+
end