Class: ReportItem
- Inherits:
-
Object
- Object
- ReportItem
- Includes:
- Comparable
- Defined in:
- lib/timesheet/report_item.rb
Instance Method Summary collapse
- #<=>(other_time_entry) ⇒ Object
- #comment ⇒ Object
- #duration ⇒ Object
- #end_slice_indication ⇒ Object
- #end_time ⇒ Object
- #end_time_sliced? ⇒ Boolean
- #formatted_duration ⇒ Object
- #formatted_end_time ⇒ Object
- #formatted_record_number ⇒ Object
- #formatted_start_time ⇒ Object
- #formatted_times ⇒ Object
-
#initialize(report, time_entry) ⇒ ReportItem
constructor
A new instance of ReportItem.
- #project ⇒ Object
- #record_number ⇒ Object
- #start_slice_indication ⇒ Object
- #start_time ⇒ Object
- #start_time_sliced? ⇒ Boolean
Constructor Details
#initialize(report, time_entry) ⇒ ReportItem
Returns a new instance of ReportItem.
7 8 9 10 |
# File 'lib/timesheet/report_item.rb', line 7 def initialize( report, time_entry) @time_entry = time_entry @report = report end |
Instance Method Details
#<=>(other_time_entry) ⇒ Object
90 91 92 |
# File 'lib/timesheet/report_item.rb', line 90 def <=>(other_time_entry) self.start_time <=> other_time_entry.start_time end |
#comment ⇒ Object
76 77 78 |
# File 'lib/timesheet/report_item.rb', line 76 def comment @time_entry.comment || "" end |
#duration ⇒ Object
28 29 30 31 |
# File 'lib/timesheet/report_item.rb', line 28 def duration return 0 if start_time == nil || end_time == nil RichUnits::Duration.new(end_time - start_time) end |
#end_slice_indication ⇒ Object
42 43 44 |
# File 'lib/timesheet/report_item.rb', line 42 def end_slice_indication (end_time_sliced?) ? '>' : ' ' end |
#end_time ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/timesheet/report_item.rb', line 46 def end_time if end_time_sliced? @report.report_end else @time_entry.end_time end end |
#end_time_sliced? ⇒ Boolean
34 35 36 |
# File 'lib/timesheet/report_item.rb', line 34 def end_time_sliced? @time_entry.to_range.cover?(@report.report_end) end |
#formatted_duration ⇒ Object
84 85 86 87 88 |
# File 'lib/timesheet/report_item.rb', line 84 def formatted_duration str = "" str << duration.strftime("%d Days ") if duration.days > 0 str << duration.strftime("%hh %mm") end |
#formatted_end_time ⇒ Object
62 63 64 |
# File 'lib/timesheet/report_item.rb', line 62 def formatted_end_time end_time.strftime("%m/%d/%Y at %I:%M:%S %p") end |
#formatted_record_number ⇒ Object
54 55 56 |
# File 'lib/timesheet/report_item.rb', line 54 def formatted_record_number sprintf("%5d", @time_entry.record_number || 0) end |
#formatted_start_time ⇒ Object
58 59 60 |
# File 'lib/timesheet/report_item.rb', line 58 def formatted_start_time start_time.strftime("%m/%d/%Y at %I:%M:%S %p") end |
#formatted_times ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/timesheet/report_item.rb', line 66 def formatted_times str = "" str << start_slice_indication str << start_time.strftime("%m/%d/%Y at %I:%M %p") str << " to " str << end_time.strftime("%m/%d/%Y at ") if ((start_time.year != end_time.year) || (start_time.yday != end_time.yday)) str << end_time.strftime("%I:%M %p") str << end_slice_indication end |
#project ⇒ Object
16 17 18 |
# File 'lib/timesheet/report_item.rb', line 16 def project @time_entry.project end |
#record_number ⇒ Object
80 81 82 |
# File 'lib/timesheet/report_item.rb', line 80 def record_number @time_entry.record_number || "N/A" end |
#start_slice_indication ⇒ Object
38 39 40 |
# File 'lib/timesheet/report_item.rb', line 38 def start_slice_indication (start_time_sliced?) ? '<' : ' ' end |
#start_time ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/timesheet/report_item.rb', line 20 def start_time if start_time_sliced? @report.report_start else @time_entry.start_time end end |
#start_time_sliced? ⇒ Boolean
12 13 14 |
# File 'lib/timesheet/report_item.rb', line 12 def start_time_sliced? @time_entry.to_range.cover?(@report.report_start) end |