Sha256: 54850a2fe8d1ec48b31b894a3ea919cfa708ccbd8b7191a8b40da7d7eff71599
Contents?: true
Size: 910 Bytes
Versions: 2
Compression:
Stored size: 910 Bytes
Contents
require 'chronic' require 'ruby-duration' module TimeDistribution class TaskList < Array attr_reader :date, :tasks def time_worked(*subjects) inject({}) do |times, t| t_subject = t.subject if subjects.empty? || subjects.include?(t_subject) if times[t_subject] times[t_subject] += t.time_taken else times[t_subject] = Duration.new(t.time_taken) end end times end end def to_hours(*subjects) inject(0) do |hours, task| if subjects.empty? || subjects.include?(task.subject) hours += task.to_hours end hours end end def to_md inject('') do |task_string, t| task_string += "- #{t.to_s}\n" end end def to_ssv inject('') do |task_string, t| task_string += "#{t.to_ssv}\n" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
time_distribution-2.3.1 | lib/time_distribution/task_list.rb |
time_distribution-2.3.0 | lib/time_distribution/task_list.rb |