Class: TimeDistribution::Task
- Inherits:
-
Object
- Object
- TimeDistribution::Task
- Defined in:
- lib/time_distribution/task.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#time_taken ⇒ Object
readonly
Returns the value of attribute time_taken.
Instance Method Summary collapse
-
#initialize(subject, time_taken, desc) ⇒ Task
constructor
A new instance of Task.
- #to_desc ⇒ Object
- #to_headline ⇒ Object
- #to_hours ⇒ Object
- #to_hours_s ⇒ Object
- #to_s ⇒ Object
- #to_ssv ⇒ Object
Constructor Details
#initialize(subject, time_taken, desc) ⇒ Task
Returns a new instance of Task.
10 11 12 13 14 |
# File 'lib/time_distribution/task.rb', line 10 def initialize(subject, time_taken, desc) @subject = subject @time_taken = SmartDuration.parse(time_taken) @desc = desc end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
5 6 7 |
# File 'lib/time_distribution/task.rb', line 5 def desc @desc end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
5 6 7 |
# File 'lib/time_distribution/task.rb', line 5 def subject @subject end |
#time_taken ⇒ Object (readonly)
Returns the value of attribute time_taken.
5 6 7 |
# File 'lib/time_distribution/task.rb', line 5 def time_taken @time_taken end |
Instance Method Details
#to_desc ⇒ Object
18 |
# File 'lib/time_distribution/task.rb', line 18 def to_desc() @desc.strip end |
#to_headline ⇒ Object
20 21 22 |
# File 'lib/time_distribution/task.rb', line 20 def to_headline "#{to_hours_s} hours of #{@subject}" end |
#to_hours ⇒ Object
24 25 26 |
# File 'lib/time_distribution/task.rb', line 24 def to_hours @time_taken.total / (60 * 60).to_f end |
#to_hours_s ⇒ Object
28 29 30 |
# File 'lib/time_distribution/task.rb', line 28 def to_hours_s format('%0.2f', to_hours) end |
#to_s ⇒ Object
16 |
# File 'lib/time_distribution/task.rb', line 16 def to_s() "#{to_headline}: #{to_desc}" end |
#to_ssv ⇒ Object
32 33 34 |
# File 'lib/time_distribution/task.rb', line 32 def to_ssv format("%-25s%10s", @subject, to_hours_s) end |