class TimeDistribution::WorkDay
Attributes
date[R]
tasks[R]
Public Class Methods
from_map(map_data)
click to toggle source
# File lib/time_distribution/work_day.rb, line 11 def self.from_map(map_data) self.new( map_data['date'], *(map_data['tasks'].map { |t| Task.from_map t }) ) end
new(date, *tasks)
click to toggle source
@param [#to_s] date Date of this work day in Chronic
compatible format. @param [Array<Task>] tasks List of tasks done in this work day. Defaults to an empty list.
# File lib/time_distribution/work_day.rb, line 20 def initialize(date, *tasks) @date = Chronic.parse(date) @tasks = if tasks.length == 1 && !tasks.first.is_a?(Task) TaskList.new(*tasks) else TaskList.new(tasks) end end
Public Instance Methods
==(other)
click to toggle source
# File lib/time_distribution/work_day.rb, line 29 def ==(other) (@date == other.date && @tasks == other.tasks) end
add_task!(task)
click to toggle source
@param [Task] task Adds task
to the list of tasks completed on this work day.
# File lib/time_distribution/work_day.rb, line 39 def add_task!(task) @tasks << task self end
time_worked(*subjects)
click to toggle source
# File lib/time_distribution/work_day.rb, line 44 def time_worked(*subjects) @tasks.time_worked *subjects end
to_h()
click to toggle source
# File lib/time_distribution/work_day.rb, line 31 def to_h { 'date' => @date.strftime('%B %-d, %Y'), 'tasks' => @tasks.map { |e| e.to_h } } end
to_hours(*subjects)
click to toggle source
# File lib/time_distribution/work_day.rb, line 46 def to_hours(*subjects) @tasks.to_hours *subjects end
to_md()
click to toggle source
# File lib/time_distribution/work_day.rb, line 48 def to_md ( @date.strftime('%b %-d, %Y') + "\n============================\n" + @tasks.to_md ) end
to_ssv() { |key| ... }
click to toggle source
# File lib/time_distribution/work_day.rb, line 56 def to_ssv ( "# #{@date.strftime('%b %-d, %Y')}\n" + ( if block_given? @tasks.to_ssv { |key| yield(key) } else @tasks.to_ssv end ) ) end