Class: Times::TimeProcesser

Inherits:
Object
  • Object
show all
Defined in:
lib/docfolio/paragraph_modules/times.rb

Overview

processes new times and dates with current times and dates

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.dateObject

Returns the value of attribute date.



15
16
17
# File 'lib/docfolio/paragraph_modules/times.rb', line 15

def date
  @date
end

.etObject

Returns the value of attribute et.



15
16
17
# File 'lib/docfolio/paragraph_modules/times.rb', line 15

def et
  @et
end

.stObject

Returns the value of attribute st.



15
16
17
# File 'lib/docfolio/paragraph_modules/times.rb', line 15

def st
  @st
end

Class Method Details

.resetObject

resets the class variables so that a new file can be parsed is called by LearningDiary (through Paragraph) when preparing to parse a new txt file



21
22
23
# File 'lib/docfolio/paragraph_modules/times.rb', line 21

def self.reset
  TimeProcesser.date = TimeProcesser.st = TimeProcesser.et = nil
end

Instance Method Details

#process_times(new_times) ⇒ Object

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



8
9
10
11
12
# File 'lib/docfolio/paragraph_modules/times.rb', line 8

def process_times(new_times)
  f_hour, f_min, t_hour, t_min = new_times
  to_start_time(f_hour, f_min) if has f_hour
  to_end_time(t_hour, t_min) if has t_hour
end