Class: MyTime::TimeProcesser

Inherits:
Object
  • Object
show all
Includes:
Tags
Defined in:
lib/docfolio/paragraph.rb

Overview

processes new times and dates with current times and dates

Constant Summary

Constants included from Tags

Tags::ALL_TAGS, Tags::CREDITABLE, Tags::SECTIONS, Tags::SPECIAL, Tags::TAGS

Instance Method Summary collapse

Methods included from Tags

#extract_date, #extract_tags, #extract_time_object

Instance Method Details

#process_times(new_times, current_times_and_dates) ⇒ Array

Takes class start end times and dates as Time objects and amends the times, advancing the date if the start time has crossed midnight.

Parameters:

  • current_times_and_dates (Array)

    An array containing the Paragraph class instance variables for the start time, end time and date (day)

  • new_times (Array)

    An array containing the from hour, from min, to hour, to min

Returns:

  • (Array)

    The updated Paragraph class instance variables for the start time, end time and date.



20
21
22
23
24
25
26
27
28
29
# File 'lib/docfolio/paragraph.rb', line 20

def process_times(new_times, current_times_and_dates)
  @start_time, @end_time, @date = current_times_and_dates
  f_hour, f_min, t_hour, t_min = new_times
  if (has f_hour) && to_st_tme(f_hour, f_min)
    t_hour  = f_hour
    t_min   = f_min
  end
  to_end_time(t_hour, t_min) if has t_hour
  [@start_time, @end_time, @date]
end