Class: TimeReport

Inherits:
Object
  • Object
show all
Defined in:
lib/timesheet/time_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#entriesObject

Returns the value of attribute entries.



9
10
11
# File 'lib/timesheet/time_report.rb', line 9

def entries
  @entries
end

#report_endObject (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_startObject (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(command_options, outstream = STDOUT)

  if (@entries.nil? || @entries.empty?)
    outstream.puts("No data available.")
  else
    constrain(command_options[:start], command_options[:end])

    detail_report(outstream) if command_options[:detail]
    summary_report(outstream) if command_options[:summary]
    byday_report(outstream) if command_options[:byday]
  end
end