Class: TimeDistribution::WorkDay
- Inherits:
-
Object
- Object
- TimeDistribution::WorkDay
- Defined in:
- lib/time_distribution/work_day.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
Instance Method Summary collapse
- #add_task!(task) ⇒ Object
-
#initialize(date, *tasks) ⇒ WorkDay
constructor
A new instance of WorkDay.
- #time_worked(*subjects) ⇒ Object
- #to_hours(*subjects) ⇒ Object
- #to_md ⇒ Object
- #to_ssv ⇒ Object
Constructor Details
#initialize(date, *tasks) ⇒ WorkDay
Returns a new instance of WorkDay.
12 13 14 15 |
# File 'lib/time_distribution/work_day.rb', line 12 def initialize(date, *tasks) @date = Chronic.parse(date) @tasks = TaskList.new(*tasks) end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
8 9 10 |
# File 'lib/time_distribution/work_day.rb', line 8 def date @date end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
8 9 10 |
# File 'lib/time_distribution/work_day.rb', line 8 def tasks @tasks end |
Instance Method Details
#add_task!(task) ⇒ Object
18 19 20 21 |
# File 'lib/time_distribution/work_day.rb', line 18 def add_task!(task) @tasks << task self end |
#time_worked(*subjects) ⇒ Object
23 |
# File 'lib/time_distribution/work_day.rb', line 23 def time_worked(*subjects) @tasks.time_worked *subjects end |
#to_hours(*subjects) ⇒ Object
25 |
# File 'lib/time_distribution/work_day.rb', line 25 def to_hours(*subjects) @tasks.to_hours *subjects end |
#to_md ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/time_distribution/work_day.rb', line 27 def to_md ( @date.strftime('%b %-d, %Y') + "\n============================\n" + @tasks.to_md ) end |
#to_ssv ⇒ Object
35 36 37 38 39 40 |
# File 'lib/time_distribution/work_day.rb', line 35 def to_ssv ( "# #{@date.strftime('%b %-d, %Y')}\n" + @tasks.to_ssv ) end |