Class: Workit::Model::Task
- Inherits:
-
Object
- Object
- Workit::Model::Task
- Includes:
- DataMapper::Resource
- Defined in:
- lib/workit/model/task.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.can_finish? ⇒ 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
32 33 34 |
# File 'lib/workit/model/task.rb', line 32 def self.can_start? self.all(:state => 'started').empty? end |
.current ⇒ Object
40 41 42 |
# File 'lib/workit/model/task.rb', line 40 def self.current self.first(:state.not => 'finished') end |
Instance Method Details
#destroy_spans ⇒ Object
48 49 50 |
# File 'lib/workit/model/task.rb', line 48 def destroy_spans self.spans.all.map(&:destroy) end |
#duration ⇒ Object
44 45 46 |
# File 'lib/workit/model/task.rb', line 44 def duration self.spans.map(&:duration).inject :+ end |