Class: TimeReport
- Inherits:
-
Object
- Object
- TimeReport
- Defined in:
- lib/timesheet/time_report.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#report_end ⇒ Object
readonly
Returns the value of attribute report_end.
-
#report_start ⇒ Object
readonly
Returns the value of attribute report_start.
Instance Method Summary collapse
- #constrain(start_time, end_time) ⇒ Object
-
#initialize(entries) ⇒ TimeReport
constructor
A new instance of TimeReport.
- #report(command_options, outstream = STDOUT) ⇒ Object
Constructor Details
#initialize(entries) ⇒ TimeReport
Returns a new instance of TimeReport.
5 6 7 |
# File 'lib/timesheet/time_report.rb', line 5 def initialize(entries) @entries = (entries.nil?) ? [] : entries.map { |entry| ReportItem.new(self, entry)} end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
9 10 11 |
# File 'lib/timesheet/time_report.rb', line 9 def entries @entries end |
#report_end ⇒ Object (readonly)
Returns the value of attribute report_end.
11 12 13 |
# File 'lib/timesheet/time_report.rb', line 11 def report_end @report_end end |
#report_start ⇒ Object (readonly)
Returns the value of attribute report_start.
10 11 12 |
# File 'lib/timesheet/time_report.rb', line 10 def report_start @report_start end |
Instance Method Details
#constrain(start_time, end_time) ⇒ Object
13 14 15 16 |
# File 'lib/timesheet/time_report.rb', line 13 def constrain(start_time, end_time) @report_start = start_time @report_end = end_time end |
#report(command_options, outstream = STDOUT) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/timesheet/time_report.rb', line 18 def report(, outstream = STDOUT) if (@entries.nil? || @entries.empty?) outstream.puts("No data available.") else constrain([:start], [:end]) detail_report(outstream) if [:detail] summary_report(outstream) if [:summary] byday_report(outstream) if [:byday] end end |