Sha256: 658fba437fb788a8c09a3ff988d20809529e23cc9283490f0e52241a5fb43211

Contents?: true

Size: 450 Bytes

Versions: 3

Compression:

Stored size: 450 Bytes

Contents

module TomatoHarvest
  class Task

    attr_reader :name
    attr_accessor :id, :pomodoros

    def initialize(name)
      @name = name
      @pomodoros = []
    end

    def log_pomodoro(seconds)
      finished_at = DateTime.now
      self.pomodoros << Pomodoro.new(seconds, finished_at)
    end

    def logged_minutes
      sum = pomodoros.inject(0) do |sum, pomodoro|
        sum + pomodoro.seconds
      end

      sum / 60.0
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tomatoharvest-0.1.1 lib/tomatoharvest/task.rb
tomatoharvest-0.1.0 lib/tomatoharvest/task.rb
tomatoharvest-0.0.1 lib/tomatoharvest/task.rb