class TimesheetReader::Formatter

Formatter class

Public Instance Methods

report(timesheets, total_hours, total_minutes) click to toggle source
# File lib/timesheet_reader/formatter.rb, line 6
def report(timesheets, total_hours, total_minutes)
  timesheets.each do |timesheet|
    filename = timesheet[:filename]
    hours = timesheet[:hours]
    minutes = timesheet[:minutes]

    print_timesheet_line(filename, hours, minutes)
  end

  hours = format_time(total_hours)
  minutes = format_time(total_minutes)
  puts "Total hours: #{hours}:#{minutes}"
end

Private Instance Methods

format_time(time) click to toggle source
# File lib/timesheet_reader/formatter.rb, line 22
def format_time(time)
  '%02d' % time
end
print_timesheet_line(filename, hours, minutes) click to toggle source