Class: Studium::ShowConflictingLvaLectures

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/utility_scripts/show_conflicting_lva_lectures/run.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/help.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/menu.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/misc.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/reset.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/report.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/constants.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/initialize.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/do_report_the_upcoming_exams.rb,
lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb

Overview

Studium::ShowConflictingLvaLectures

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect
A =
#

A

This special constant denotes a very important date, such as the '01.10.2018' (first october in the year 2018). Based on this date, we can also input capital letters into this class, such as “conflict A”, “conflict B”, “conflict C” - where conflict is an alias to this class here. A means this set date, aka '01.10.2018', B then simply refers to the date after this date listed at A, C then means the date after B and so on, and so forth.

The idea behind this is to just quickly input single letters and still get some meaningful output, without having to type whole years in the dd.mm.yyyy schemata, as the latter can become fairly tedious.

Ideally, a monday may be used for A, simply because this is the start of the week.

#
'18.10.2020'
ARRAY_SHORTCUTS_FOR_TOMORROW =
#

ARRAY_SHORTCUTS_FOR_TOMORROW

Some string-aliases, stored as array, for “tomorrow”.

#
%w(
  morgen
  tomorrow
  +1
  +
)
ARRAY_SHORTCUTS_FOR_THE_DAY_AFTER_TOMORROW =
#

ARRAY_SHORTCUTS_FOR_THE_DAY_AFTER_TOMORROW

#
%w(
  übermorgen
  +2
)

Constants inherited from Base

Base::ARRAY_HTML_COLOURS_IN_USE, Base::CHECK_FOR_INCORRECT_ENTRIES_IN_THE_QUESTION_ANSWER_FILE_THAT_SHOULD_BE_COMMENTS, Base::COLOURS, Base::COMMON_YEAR_DAYS_IN_MONTH, Base::GRAY, Base::LEFT_PADDING, Base::N_CHARACTERS_PER_LINE, Base::UNICODE_RIGHT_ARROW

Constants included from Colours

Colours::COLOURS

Instance Method Summary collapse

Methods inherited from Base

#add_proper_year_entry_to_this_line, #already_solved_this_lva_number?, #append_what_into, #available_topics_as_short_name, #average_grade, #bachelor_master_or_diploma, #base_dir?, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #cliner, #colour_for_ects_points, #colourize_percentage, #commandline_arguments?, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #datum?, #day_month_year, #delete_file, #directory_of_the_exam_topics?, #directory_to_my_exam_topics, #directory_to_the_exam_topics?, #disable_colours, #disable_colours_globally, #do_not_be_verbose, #do_not_use_opn, #do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?, #does_this_line_include_a_german_weekday?, #does_this_line_include_a_html_colour?, #e, #ecomment, #editor?, #ee, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_main_encoding, #ensure_that_the_log_directory_exists, #eparse, #erev, #esystem, #etomato, #exit_program, #expand_topic, #extract_dd_mm_yyyy, #file_lecture_information?, #file_read_with_proper_encoding, #filter_away_invalid_questions, #find_corresponding_exam_topic, #first_argument?, #first_non_hyphen_argument?, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #is_a_master_lecture?, #is_a_weekday?, #is_connected_to_the_www?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_valid_html_colour?, #is_this_day_today?, #konsole_support?, #last_file?, #lectures_from_indi1, #lectures_from_indi2, #lectures_from_indi3, #lectures_from_indi4, #lectures_from_the_bachelor_genetik_curriculum, #lectures_from_the_individual_vektor_curricula, #load_yaml_dataset, #move_file, #n_days_difference_from_today_to_this_day, #no_ext_name, #no_file_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_editor, #opnn, #path_to_exam_topic?, #read_dataset_from_a_curriculum_file, #read_in_exam_dataset_from_this_file, #read_this_file_with_default_encoding, #readlines_from_this_input_file, #register_sigint, #remove_empty_strings, #remove_escape_sequences, #remove_internal_comments, #remove_leading_comments, #remove_leading_weekday_names_from, #remove_newlines, #remove_tags_from_this_input, #rename_kde_konsole_tab, #rename_konsole_tab?, #replace_all_html_colours_in_this, #replace_bold_token_with_default_colour, #replace_italic_token_with_default_colour, #replace_italic_token_with_this_colour, #replace_regular_numbers_with_unicode_numbers, #replace_underline_token_with_default_colour, #replace_underline_token_with_this_colour, #return_all_bachelor_lectures, #return_all_exams_on_this_day, #return_all_numbers_from, #return_all_registered_curricula, #return_all_steop_lectures, #return_current_year, #return_dataset_for_this_topic, #return_dataset_from_this_curriculum_file, #return_dd_mm_yy_and_time_from, #return_directory_for, #return_ects_points_from_these_lectures, #return_either_grey_or_the_custom_colour_for_answers, #return_either_grey_or_the_custom_colour_for_questions, #return_file_for_this_curriculum, #return_german_name_for_this_english_month, #return_german_weekday_of?, #return_hh_mm_ss_from, #return_hour_from_this, #return_lectures_from_bachelor_vektor_curriculum, #return_lectures_with_at_the_least_one_upcoming_exam, #return_local_path_of_this_pwdstud, #return_lva_number_of_this_lecture, #return_month_fitting_to_this_input, #return_n_days_until_monday, #return_n_days_until_sunday, #return_n_exam_questions_in, #return_n_questions_were_answered_for_this_topic, #return_name_of_the_weekday, #return_name_of_this_curriculum, #return_name_of_this_curriculum_based_on_its_id_number, #return_opnn, #return_passed_courses, #return_pwd, #return_random_curriculum, #return_sanitized_dataset_from_the_file_lecture_information, #return_solved_lectures, #return_steop_lectures, #return_the_remote_homepage_url, #return_this_line_has_n_characters_as_html_colour_tags, #return_title_from_this_curriculum_file, #rev, #right_arrow?, #rinstall2, #roebe_exam_directory?, #ruby_src_dir_at_home?, #runmode?, #sanitize_this_topic, #sanitize_url, #select_lectures_with_this_key, #set_be_quiet, #set_be_verbose, #set_commandline_arguments, #set_commandline_mode, #set_runmode, #set_this_cd_alias_to, #set_www_mode, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #simp, #sort_these_lecture_names_by_time, #spacer, #swarn, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_the_rcfiles, #turn_this_array_into_the_full_dataset, #unicode_blocks_line, #use_colours?, #use_opn?, #vertical_bar?, #web_liner, #weekday?, #weekdays?, #word_wrap, #write_what_into, #www_connection_is_unavailable, #www_mode?, #yaml_dir?

Methods included from Colours

#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, #sfancy, sfile, #sfile, simp, #simp, slateblue, steelblue, #steelblue, #swarn, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow

Constructor Details

#initialize(use_this_date = DEFAULT_DATE, run_already = true) ⇒ ShowConflictingLvaLectures

#

initialize

#


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/initialize.rb', line 14

def initialize(
    use_this_date = DEFAULT_DATE,
    run_already   = true
  )
  reset
  use_this_date = check_for_commandline_arguments(
    use_this_date
  )
  set_use_this_date(
    use_this_date
  )
  run if run_already
end

Instance Method Details

#append_onto_the_main_hash(i = @use_these_dates) ⇒ Object

#

append_onto_the_main_hash

#


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/misc.rb', line 50

def append_onto_the_main_hash(
    i = @use_these_dates
  )
  our_date_of_interest = Time.parse(i)
  @dataset.each_pair {|name_of_the_lecture, inner_hash|
    # ===================================================================== #
    # === Check for exams on that day
    #
    # First find relevant exams: We will also register the lva_dates
    # but check them later.
    # ===================================================================== #
    exams = inner_hash['exams']
    if exams
      begin
        # First, check for flawed entries:
        if exams.is_a?(Array) and exams.first.nil?
          opne 'A '+steelblue('problem')+' occurred for '+
               sfancy(name_of_the_lecture)+'.'
          opne 'There is a faulty exams: entry. Please correct '\
               'this before we can continue'
          pp exams
          exit
        end
        array_exams_on = remove_weekday_names_from(
          exams
        ).map(&:strip)
        array_exams_on.compact!
        array_exams_on.map!(&:strip).map {|line|
          Time.parse(line.delete(','))
        }
      rescue ArgumentError => error
        opnn; e 'We encountered an error for '\
                'the lecture called `'+
                royalblue(name_of_the_lecture)+'`:'          
        pp error
        opnn; e 'Exiting now - please fix this problem.'
        exit
      end
    end
    # ===================================================================== #
    # Check for the lva-dates entry next.
    # ===================================================================== #
    lva_dates = inner_hash['lva_dates']
    if lva_dates
      begin
        array_lva_dates_on = remove_weekday_names_from(
          lva_dates
        ).map(&:strip).map {|line| line.delete(',').strip }
        array_lva_dates_on.map! {|line|
          Time.parse(line)
        }
      rescue ArgumentError => error
        opnn; e 'Problem with lecture name: '+
                sfancy(name_of_the_lecture)
        pp error
      end
    end
    if exams.nil?
    else
      if exams
        # =================================================================== #
        # Ok, we have found at the least one exam here.
        # =================================================================== #
        exams.map! {|line| line.to_s.strip }
        if exams.first.empty?
          opnn; e 'Empty exams-entry for '+
                  slateblue(name_of_the_lecture)
        end
        # =================================================================== #
        # Next, we must find out if the exams are on the same date.
        # This works if we use date-objects via Time.at().to_date.
        # =================================================================== #
        if array_exams_on.any? {|time_entry|
            date1 = time_entry
            if date1.is_a? String
              date1 = Time.parse(date1)
            end
            if date1.respond_to? :to_date
              date1 = date1.to_date
            end
            date2 = our_date_of_interest.to_date
            # =============================================================== #
            # Must convert date1 to start at 00:00:00 too.
            # =============================================================== #
            date1 = Time.parse(
              date1.day.to_s+'.'+date1.month.to_s+'.'+date1.year.to_s
            ).to_date if date1.respond_to? :day
            date1 === date2
          }
          main_hash?[:exams] << name_of_the_lecture
        end
      end
    end
    # ===================================================================== #
    # Next check for lva-dates.
    # ===================================================================== #
    if lva_dates.nil?
    else
      # =================================================================== #
      # Next, we must find out if the exams are on the same date.
      # This works if we use date-objects via Time.at().to_date.
      # =================================================================== #
      if array_lva_dates_on.any? {|time_entry|
          date1 = time_entry.to_date
          date2 = our_date_of_interest.to_date
          # =============================================================== #
          # Must convert date1 to start at 00:00:00 too.
          # =============================================================== #
          date1 = Time.parse(date1.day.to_s+'.'+date1.month.to_s+'.'+date1.year.to_s).to_date
          # =============================================================== #
          # Check whether it is from the past year:
          # =============================================================== #
          if date2.year - date1.year > 0
            register_this_lecture_having_a_wrong_date(
              name_of_the_lecture.strip, date1
            )
            e crimson('There may be a wrong date (year) set '\
              'for the lecture `')+royalblue(name_of_the_lecture)+
              crimson('`.')
            pp date1
          end
          date1 === date2
        }
        main_hash?[:lva_dates] << name_of_the_lecture
      end
      if @show_raw_data
        opnn; e royalblue('Debug output of the variable called array_lva_dates_on')
        opnn; e slateblue('For the lecture called ')+lightgreen(name_of_the_lecture)
        e
        pp array_lva_dates_on
        e
        e 'The inner_hash dataset was:'
        e
        pp inner_hash
        e
      end
    end
  }
  if @show_raw_data
    opnn; e royalblue('Debug output:')
    e
    pp main_hash?
    e
  end
  report_lectures_having_an_outdated_year
end

#append_university(i) ⇒ Object

#

append_university

This will properly format and colourize the “university-string”, before returning it. It is to be used to append it to the displayed string.

#


80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 80

def append_university(i)
  # Still have to modify these two:
  #  VetMed
  case i
  when 'TU Vienna'
    i = 'TU'
  when 'Uni Wien'
    i = 'UniWien'
  end
  i = " #{i.center(8)}"
  return dodgerblue(i) # Or deepskyblue
end

#check_for_commandline_arguments(i) ⇒ Object

#

check_for_commandline_arguments

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/misc.rb', line 14

def check_for_commandline_arguments(i)
  if i.is_a? Array
    if i.any? {|line| line.start_with?('--') }
      # =================================================================== #
      # Ok, the user has provided at the least one -- argument.
      # =================================================================== #
      set_commandline_arguments(
        i.select {|inner_line| inner_line.start_with?('--') }
      )
      # =================================================================== #
      # And reject them, too.
      # =================================================================== #
      i.reject! {|inner_line| inner_line.start_with?('--') }
    end
  end
  i # We must return this here.
end

#colour_for_exams(i, optional_priority = nil, optional_registered_for_that_exam = false) ⇒ Object

#

colour_for_exams

#


150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 150

def colour_for_exams(
    i,
    optional_priority                 = nil,
    optional_registered_for_that_exam = false
  )
  if optional_registered_for_that_exam
    orangered(i)+
    orangered(" #{left_arrow} [Registered for this exam]")
  else
    case optional_priority
    when 1
      crimson(i)+
      crimson(" #{left_arrow} [High Priority Exam]")
    else
      springgreen(i)
    end
  end
end

#colour_for_index_strings(i) ⇒ Object

#

colour_for_index_strings

#


136
137
138
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 136

def colour_for_index_strings(i)
  powderblue(i)
end

#colour_for_lectures(i) ⇒ Object Also known as: colour_for_vorbesprechungs_termin

#

colour_for_lectures

#


211
212
213
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 211

def colour_for_lectures(i)
  turquoise(i)
end

#colour_for_preliminary_meetings(i) ⇒ Object

#

colour_for_preliminary_meetings

#


143
144
145
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 143

def colour_for_preliminary_meetings(i)
  rosybrown(i)
end

#colourize_weekday(i) ⇒ Object

#

colourize_weekday

#


112
113
114
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 112

def colourize_weekday(i)
  limegreen(i)
end

#colourized_orangered(i) ⇒ Object Also known as: colourize_via_orangered

#

colourized_orangered

#


523
524
525
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 523

def colourized_orangered(i)
  orangered(i)
end

#dataset?Boolean Also known as: main_dataset?

#

dataset?

#

Returns:

  • (Boolean)


40
41
42
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 40

def dataset?
  @dataset
end

#display_these_exams_on_that_day(i) ⇒ Object

#

display_these_exams_on_that_day

This is the method that will report which exams will happen during the given input-day.

#


221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 221

def display_these_exams_on_that_day(i)
  index = 0
  e
  i.each {|name_of_the_lecture, date_of_the_lecture| index += 1
    _ = date_of_the_lecture
    padded_index = "#{index})".rjust(3)
    colourized_and_padded_index = powderblue(padded_index)
    priority         = return_dataset_of_this_lecture(name_of_the_lecture)[:priority]
    which_university = return_dataset_of_this_lecture(name_of_the_lecture)[:university].to_s
    registered_for_an_upcoming_exam_at = @dataset[name_of_the_lecture]['registered']
    if registered_for_an_upcoming_exam_at
      if registered_for_an_upcoming_exam_at.is_a? Array
        # ================================================================= #
        # Note that the array above may have some additional ' '
        # characters, so we apply .squeeze() on it.
        #
        # An example for this is:
        #
        #   "Dienstag     12.06.2018, 14:00-16:00, Ort: Foobar"
        # ================================================================= #
        registered_for_an_upcoming_exam_at.map! {|entry| entry.squeeze(' ') }
        registered_for_an_upcoming_exam_at = registered_for_an_upcoming_exam_at.first
      end
      registered_for_an_upcoming_exam_at = remove_leading_weeknames(
        registered_for_an_upcoming_exam_at
      )
    end
    case which_university
    when 'TU Vienna'
      which_university = 'TU Wien'
    end
    padded_which_university = " #{which_university}".center(10)
    colourized_and_padded_which_university = plum('['+padded_which_university+'] ')
    # ===================================================================== #
    # In the event that priority is 1, we will use slightly different
    # colours - aka red.
    # ===================================================================== #
    are_we_registered_for_that_exam = false
    if registered_for_an_upcoming_exam_at # to prevent nil-entries
      # =================================================================== #
      # The line may be like this:
      #   "18.06.2018, 14:00-16:00, Ort: Hörsaal 2 UZA 1 Biozentrum 2.249 1.OG"
      # =================================================================== #
      splitted = registered_for_an_upcoming_exam_at.split(',')
      first    = splitted.first
      if first == input_given?
        are_we_registered_for_that_exam = true
      end
    end
    return_colourized_entry_for_an_upcoming_exam = colour_for_exams(
      '['+return_dd_mm_yy_and_time_from(date_of_the_lecture).to_s.rjust(19,'0')+']',
      priority,
      are_we_registered_for_that_exam
    )
    padded_name_of_the_lecture = name_of_the_lecture.ljust(@n_ljust)
    # ===================================================================== #
    # If we are registered for that particular exam then we
    # will use a slightly brighter colour.
    # ===================================================================== #
    if are_we_registered_for_that_exam
      @array_we_have_registered_for_these_exams_on_that_day << [
        name_of_the_lecture, date_of_the_lecture
      ]
      colourized_and_padded_name_of_the_lecture =
        cadetblue(padded_name_of_the_lecture)
    else
      colourized_and_padded_name_of_the_lecture =
        cornflowerblue(padded_name_of_the_lecture)
    end
    # ===================================================================== #
    # And finally, report which exams will happen on that day next,
    # on the commandline.
    # ===================================================================== #
    e @left_pad+
      colourized_and_padded_index+ # The index such as ' 1)'
      ' '+
      colourized_and_padded_name_of_the_lecture+ # The name of the lecture.
      colourized_and_padded_which_university+
      return_colourized_entry_for_an_upcoming_exam
  }
  e
end

#display_these_lectures_on_that_day(i) ⇒ Object

#

display_these_lectures_on_that_day

This method will display the lectures on that given day, along with some additional information to make it easier to read what is all happening on that day.

#


384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 384

def display_these_lectures_on_that_day(i)
  index = 0
  # ======================================================================= #
  # Obtain a reference to the main dataset next:
  # ======================================================================= #
  main_dataset = main_dataset?
  # ======================================================================= #
  # Merge in all exams that occur on that day:
  # ======================================================================= #
  unless @array_we_have_registered_for_these_exams_on_that_day.empty?
    @array_we_have_registered_for_these_exams_on_that_day.each {|element|
      # =================================================================== #
      # We have to re-set the time counter for these elements, as they
      # may have the wrong timezone-offset, which would mess up our
      # sorting done at a later point.
      # =================================================================== #
      second_element = Studium.normalize_time(
        element.last
      )
      element[-1] = second_element
      # =================================================================== #
      # We will add that element onto the dataset, aka i - but before
      # we do so, we have to remove the old element from our dataset.
      # =================================================================== #
      i.reject! {|array|
        name = array.first
        first_entry = element.first
        name == first_entry
      }
      i << element
    }
  end
  sorted_by_date = i.sort_by {|name_of_the_lecture, time_entry|
    Time.parse(time_entry.to_s)
  }
  e; sorted_by_date.each {|name_of_the_lecture, date_of_the_lecture| index += 1
    _ = date_of_the_lecture
    # Pad the index a bit:
    padded_index = ("#{index})").rjust(3)
    if this_exam_happens_on_that_day?(name_of_the_lecture)
      colourized_and_padded_index = colourize_via_orangered(padded_index)
    else
      colourized_and_padded_index = colour_for_index_strings(padded_index)
    end
    priority               = main_dataset[name_of_the_lecture][:priority]
    lecture_type           = main_dataset[name_of_the_lecture][:type] # Can be "VO" or "VO+SE" and so forth.
    name_of_the_university = main_dataset[name_of_the_lecture][:university]
    do_we_participate      = main_dataset[name_of_the_lecture][:currently_participating_in_this_course]
    # ===================================================================== #
    # We will store everything in the String referenced via the variabled
    # called "result".
    # ===================================================================== #
    result = @left_pad+colourized_and_padded_index               # First show the index
    if do_we_participate
      result[1,1] = mediumseagreen('') # This icon denotes that we currently participate in this course.
    end
    result << properly_colourize_this_lecture_type(lecture_type) # Next the lecture-type such as "VO" or "SE" etc.
    padding_to_use = @n_ljust
    if lecture_type.size > 2
      # =================================================================== #
      # In this case, use a slightly shorter padding.
      # =================================================================== #
      padding_to_use -= (lecture_type.size - 2)
    end
    # ===================================================================== #
    # Make too long names shorter (truncate):
    # ===================================================================== #
    chop_off_at_this_offset = @n_ljust - 4
    if name_of_the_lecture.size > chop_off_at_this_offset
      name_of_the_lecture = name_of_the_lecture[0 .. (chop_off_at_this_offset - 6)]+' [...]'
    end
    padded_name_of_the_lecture = name_of_the_lecture.ljust(padding_to_use)
    # ===================================================================== #
    # The normal colour for lectures here is slateblue; but if the
    # lecture is of high priority, aka priority 1, then a slightly
    # brighter colour will be used, to also visually denote that
    # this lecture is more important.
    # ===================================================================== #
    if this_exam_happens_on_that_day?(name_of_the_lecture)
      # =================================================================== #
      # In this case we will also pad anew:
      # =================================================================== #
      result << orangered(
        (
          "#{name_of_the_lecture} #{left_arrow} #{return_people_cheering_for_an_exam}"
        ).ljust(padding_to_use)
      )
    else
      case priority
      when 1
        result << mediumpurple(padded_name_of_the_lecture) # Now the name of the lecture.
      else
        result << slateblue(padded_name_of_the_lecture)    # Now the name of the lecture.
      end
    end
    result << colour_for_lectures(
                '['+return_dd_mm_yy_and_time_from(date_of_the_lecture).to_s.rjust(19,'0')+']'
              )
    # ===================================================================== #
    # Find out whether this exame happens on the day:
    # ===================================================================== #
    if this_exam_happens_on_that_day?(name_of_the_lecture)
      # =================================================================== #
      # Registered exams will appear in another colour:
      # =================================================================== #
      result << skyblue(' [')+return_colourized_people_cheering_for_an_exam+skyblue(']')
    elsif priority.to_i == 1
      result << skyblue(' [')+orange('Priorität: '+priority.to_s)+skyblue(']')
    else
      result << skyblue(" [Priorität: #{priority}]")
    end
    # ===================================================================== #
    # Next, append the university.
    # ===================================================================== #
    result << append_university(name_of_the_university)
    e result
  }
  e
end

#do_report_all_preliminary_meetings_on_that_day(i) ⇒ Object

#

do_report_all_preliminary_meetings_on_that_day

#


179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 179

def do_report_all_preliminary_meetings_on_that_day(i)
  selection = @original_dataset.select {|a, b|
    b.has_key?('vorbesprechung') and
    b['vorbesprechung'].include?(i.to_s)
  }
  index = 0
  if selection.empty?
  else
    # ===================================================================== #
    # === "The following preliminary meetings happen on ... "
    # ===================================================================== #
    e 'The following '+colour_for_preliminary_meetings('preliminary meetings')+
        ' happen on '+orange(i)+
        ' ('+simp(translate_dd_mm_yyy_to_weekday(i))+').'
    e
    selection.each_pair {|name_of_the_lecture, hash| index += 1
      vorbesprechungs_day = hash['vorbesprechung']
      colourized_and_padded_index =
        '   '+colour_for_index_strings(index.to_s+')')
      e colourized_and_padded_index+' '+
        sfancy(name_of_the_lecture.ljust(@n_ljust+5))+
        colour_for_vorbesprechungs_termin(
          '['+vorbesprechungs_day+']'
        )
    }
  end
  e
end

#do_report_the_upcoming_exams(i = main_day? ) ⇒ Object

#

do_report_the_upcoming_exams

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/do_report_the_upcoming_exams.rb', line 14

def do_report_the_upcoming_exams(
    i = main_day?
  )
  i = i.dup if i.frozen?
  i.strip! # Get rid of irrelevant ' ', just in case.
  main_day = i
  exams_on_that_day = main_hash?[:exams]
  unless exams_on_that_day.empty?
    # ===================================================================== #
    # === "The following exams happen on ..."
    # ===================================================================== #
    e 'The following '+
      colour_for_exams('exams')+
      ' happen on '+orange(main_day)+
      ' ('+colourize_weekday(translate_dd_mm_yyy_to_weekday(main_day))+
      ')'+
      darkslategray(':')
    sorted_exams_on_that_day = []
    exams_on_that_day = exams_on_that_day.each {|name_of_the_lecture|
      pointer = main_dataset?[name_of_the_lecture]
      selection = pointer['exams'].select {|line|
        line.include? i
      }
      if selection
        if selection.empty?
          opnn; e "The selection is empty for the day #{sfancy(i.to_s)}."
          opnn; e "The name of the lecture was #{sfancy(name_of_the_lecture)}"
          pp exams_on_that_day
        else
          selection_match = selection.first.strip
          sorted_exams_on_that_day << [
            name_of_the_lecture, Time.parse(selection_match)
          ]
        end
      end
    }
    sorted_exams_on_that_day = sorted_exams_on_that_day.sort_by {|a,b|
      b
    }
    display_these_exams_on_that_day(sorted_exams_on_that_day)
  else
    e "No exams were found on the day #{orange(main_day)}"\
      " (#{sfancy(return_weekday_for(main_day))})."
  end
end

#do_show_raw_dataObject

#

do_show_raw_data

#


35
36
37
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/misc.rb', line 35

def do_show_raw_data
  @show_raw_data = true
end

#filter_the_main_datasetObject

#

filter_the_main_dataset

#


63
64
65
66
67
68
69
70
71
72
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 63

def filter_the_main_dataset
  @dataset.reject! {|name_of_the_lecture, inner_hash|
    inner_hash.has_key?(:already_solved) and
    inner_hash[:already_solved] == true 
  }
  @dataset.select! {|name_of_the_lecture, inner_hash|
    inner_hash.has_key?('lva_dates') or
    inner_hash.has_key?('exams')
  }
end

#input_given?Boolean

#

input_given?

This will return the first date.

#

Returns:

  • (Boolean)


56
57
58
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 56

def input_given?
  @use_these_dates.first
end

#left_arrowObject

#

left_arrow

#


172
173
174
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 172

def left_arrow
  ''
end

#main_hash?Boolean

#

main_hash?

#

Returns:

  • (Boolean)


47
48
49
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 47

def main_hash?
  @main_hash
end
#

menu (menu tag)

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/menu.rb', line 14

def menu(
    i = @commandline_arguments
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i
    # ===================================================================== #
    # === conflict 15.01.2019 --show-raw-data
    # ===================================================================== #
    when /^-?-?show(-|_)?raw(-|_)?data$/,
         /^-?-?show(-|_)?raw$/
      do_show_raw_data
    # ===================================================================== #
    # === slectures --help
    # ===================================================================== #
    when /help$/
      show_help
      exit
    # ===================================================================== #
    # === slectures --lva-dates-of=301246
    #
    # This entry point allows us to show all LVA-dates of a specific
    # lecture, by using the lecture-id for this.
    #
    # Invocation examples:
    #
    #   slectures --lvaid=941110
    #
    # ===================================================================== #
    when /^-?-?lva(-|_)?dates(-|_)?of=(.+)$/i,
         /^-?-?for=(.+)$/i,
         /^-?-?lvaid=(.+)$/i
      _ = $1.to_s.dup
      _ = $3.to_s.dup if $3
      show_lva_dates_of_this_lecture(_)
    end
  end
end

#prepare_dataset_and_then_report_for_this_date(this_date) ⇒ Object

#

prepare_dataset_and_then_report_for_this_date

#


200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/misc.rb', line 200

def prepare_dataset_and_then_report_for_this_date(
    this_date
  )
  reset_internal_dataset
  filter_the_main_dataset
  append_onto_the_main_hash(
    this_date
  )
  report(
    this_date
  )
  store_this_date_into_a_local_file
end

#properly_colourize_this_lecture_type(lecture_type) ⇒ Object

#

properly_colourize_this_lecture_type

Lecture types such as SE, UE and so forth, will be displayed in a slightly brighter colour, to denote that they are more important than other lecture-types such as VO.

#


100
101
102
103
104
105
106
107
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 100

def properly_colourize_this_lecture_type(lecture_type)
  _ = ' ['+lecture_type+'] '
  if is_prüfungsimmanent?(lecture_type)
    darkturquoise(_)
  else
    steelblue(_)
  end
end

#register_this_lecture_having_a_wrong_date(name_of_the_lecture, date) ⇒ Object

#

register_this_lecture_having_a_wrong_date

#


333
334
335
336
337
338
339
340
341
342
343
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 333

def register_this_lecture_having_a_wrong_date(
    name_of_the_lecture, date
  )
  # ======================================================================= #
  # We will only register the first incorrect lecture; the others will
  # be ignored. This way the user can fix the flawed dataset.
  # ======================================================================= #
  unless @hash_these_lectures_have_a_wrong_date.has_key? name_of_the_lecture.strip
    @hash_these_lectures_have_a_wrong_date[name_of_the_lecture.strip] = date
  end
end

#report(i = main_day? ) ⇒ Object

#

report (report tag)

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/report.rb', line 14

def report(
    i = main_day?
  )
  e # An initial newline to make this prettier.
  opnn { :no_colon }
  header_string = (" [Heutiger Tag: #{return_weekday}, #{dd_mm_yyyy}]").
                  rjust(50)
  if use_unicode_symbols? and Object.const_defined? :Roebe
    lindex = header_string.index('[')
    header_string[lindex, 0] = '|'
    splitted = header_string.split('|')
    splitted[0] = crimson(splitted[0]+Roebe.shamrock) # Add a shamrock-unicode icon.
    splitted[1] = lightseagreen(splitted[1])+
                  crimson(Roebe.shamrock) # Add the clear-sun weather icon.
    header_string = lightseagreen(splitted.join)

  else
    header_string = lightseagreen(header_string)
  end
  ee header_string
  e
  e
  if Studium.is_this_day_a_holiday?(i)
    opnn; e "Note that the day #{sfancy(i)} is a holiday."
    e
  end
  # ======================================================================= #
  # First, look if there are any "vorbesprechungen", aka
  # "preliminary meetings". If so, we will show these first.
  # ======================================================================= #
  if Studium.is_a_vorbesprechungs_day?(i)
    do_report_all_preliminary_meetings_on_that_day(i)
  end
  # ======================================================================= #
  # Next, report the exams. The lva-dates will be reported lateron.
  # ======================================================================= #
  do_report_the_upcoming_exams(i)
  lva_dates_on_that_day = main_hash?[:lva_dates]
  sorted_lectures_on_that_day = []
  main_day = i
  unless lva_dates_on_that_day.empty?
    # ===================================================================== #
    # === "The following lectures occur on"
    # ===================================================================== #
    result = 'The following '.dup
    if use_unicode_symbols? and Object.const_defined? :Roebe
      result << lightgreen(Roebe.white_sun_with_rays)+' '
    end
    result << colour_for_lectures('lectures')+
              ' occur on '+orange(main_day)+
              ' ('+colourize_weekday(translate_dd_mm_yyy_to_weekday(main_day))+
              ')'+
              darkslategray(':')
    e result
    # ===================================================================== #
    # Iterate over our lectures next:
    # ===================================================================== #
    lva_dates_on_that_day.each {|name_of_the_lecture|
      pointer   = main_dataset?[name_of_the_lecture]
      selection = pointer['lva_dates'].select {|line|
        line.include? i
      }
      if selection
        _ = selection.first
        _.strip! if _
        # ================================================================= #
        # The _ variable is now something like this: "16.04.2018, 18:00-19:30"
        # ================================================================= #
        _.delete!(',')
        _.squeeze!(' ')
        if _.include? '-'
          _ = _.split('-').first+':00'
        end
        begin
          sorted_lectures_on_that_day << [
            name_of_the_lecture, Time.parse(_)
          ]
        rescue Exception => error
          e 'A problem occurred.'
          pp error
          pp name_of_the_lecture
          pp _
          exit
        end
      end
    }
    sorted_lectures_on_that_day = sorted_lectures_on_that_day.sort_by {|a,b|
      b
    }
    # ===================================================================== #
    # === The lectures on that day
    #
    # Finally, we will display the lectures that happen on that day.
    # ===================================================================== #
    display_these_lectures_on_that_day(
      sorted_lectures_on_that_day
    )
  else
    e "No lectures were found on the day #{orange(main_day)}"\
      " (#{sfancy(return_weekday_for(main_day))})."
  end
  e
end

#report_lectures_having_an_outdated_yearObject

#

report_lectures_having_an_outdated_year

#


632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 632

def report_lectures_having_an_outdated_year
  unless @hash_these_lectures_have_a_wrong_date.empty?
    @hash_these_lectures_have_a_wrong_date.each_pair {|name_of_the_lecture, date|
      @reported_n_lectures_having_a_wrong_date += 1
      unless @reported_n_lectures_having_a_wrong_date > 3
        # ================================================================= #
        # Don't show more than 3 outdated dates.
        # ================================================================= #
        e crimson('There may be a wrong date (year) set '\
          'for the lecture `')+royalblue(name_of_the_lecture)+
          crimson('`.')
        pp date
      end
    }
  end
end

#resetObject

#

reset (reset tag)

#


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/reset.rb', line 14

def reset
  super()
  reset_internal_dataset
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @commandline_arguments
  # ======================================================================= #
  @commandline_arguments = []
  # ======================================================================= #
  # === @store_into_this_file
  # ======================================================================= #
  @store_into_this_file =
    "#{log_dir?}last_date_for_conflicting_lva_lectures.md"
  # ======================================================================= #
  # === @show_raw_data
  #
  # The next instance variable determines whether we will show some
  # additional debug information or not. By default we will not do
  # so, hence why it is set to false.
  # ======================================================================= #
  @show_raw_data = false
  # ======================================================================= #
  # === @reported_n_lectures_having_a_wrong_date
  # ======================================================================= #
  @reported_n_lectures_having_a_wrong_date = 0
end

#reset_internal_datasetObject

#

reset_internal_dataset

Put variables into this method here only if you really wish to reset them. Commandline arguments should normally NOT be reset in this method.

#


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/reset.rb', line 51

def reset_internal_dataset
  # ======================================================================= #
  # The @main_hash will store :exams and :lectures as separate entities.
  # ======================================================================= #
  @main_hash = {}
  @main_hash[:exams] = []
  @main_hash[:lva_dates] = []
  # ======================================================================= #
  # === @array_we_have_registered_for_these_exams_on_that_day
  # ======================================================================= #
  @array_we_have_registered_for_these_exams_on_that_day = []
  # ======================================================================= #
  # === @original_dataset
  # ======================================================================= #
  @original_dataset = return_dataset_from_file_lecture_information
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = @original_dataset.dup
  # ======================================================================= #
  # === @n_ljust
  # ======================================================================= #
  @n_ljust = 78
  # ======================================================================= #
  # === @left_pad
  # ======================================================================= #
  @left_pad = '  ' # This one is displayed when showing indices in this class.
  # ======================================================================= #
  # === @hash_these_lectures_have_a_wrong_date
  # ======================================================================= #
  @hash_these_lectures_have_a_wrong_date = {}
end

#return_colourized_people_cheering_for_an_examObject

#

return_colourized_people_cheering_for_an_exam

#


514
515
516
517
518
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 514

def return_colourized_people_cheering_for_an_exam
  colourized_orangered(
    return_people_cheering_for_an_exam
  )
end

#return_dataset_of_this_lecture(i) ⇒ Object

#

return_dataset_of_this_lecture

#


129
130
131
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 129

def return_dataset_of_this_lecture(i)
  @dataset[i]
end

#return_people_cheering_for_an_examObject

#

return_people_cheering_for_an_exam

#


507
508
509
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 507

def return_people_cheering_for_an_exam
  '\\o/ EXAM \\o/'
end

#runObject

#

run

#


14
15
16
17
18
19
20
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/run.rb', line 14

def run
  ensure_that_the_log_directory_exists # Make sure that the log dir exists.
  menu # Pass the commandline arguments into the menu() interface.
  @use_these_dates.each {|this_date|
    prepare_dataset_and_then_report_for_this_date(this_date)
  }
end

#set_use_this_date(i = nil) ⇒ Object

#

set_use_this_date (set tag)

This will set the date that we are interested in. If the input is an Array then we will work on a String. In general, the String should be in the format dd.mm.yyyy such as '25.02.2018'.

#


534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 534

def set_use_this_date(
    i = nil
  )
  i = DEFAULT_DATE if i.nil?
  # ======================================================================= #
  # === Handle Arrays next
  # ======================================================================= #
  if i.is_a?(Array)
    # ===================================================================== #
    # First, we will reject all entries that are a weekday, such as
    # "Freitag". The reason for this behaviour is because we can also
    # invoke this class here via e. g.:
    #
    #   conflict Freitag 25.10.2019
    #
    # But we don't care about the weekday name here; the dd.mm.yyyy format
    # is sufficient. So, let's modify the array.
    # ===================================================================== #
    i.reject! {|entry| weekdays?.include?(entry.capitalize) }
    first = i.first
    if i.empty?
      i = return_dd_mm_yyyy
    elsif first.is_a?(String) and first.include?('-') and (first =~ /\d+/)
      require 'studium/utility_scripts/expand_time_range.rb'
      i = Studium.expand_these_lectures(i)
    elsif first !~ /\d+/ # If it does not have a number but is not empty.
      case first
      # =================================================================== #
      # === default
      # =================================================================== #
      when 'default','def'
        if File.exist? @store_into_this_file
          opnn; e 'Reading from the file'
          opnn; e "  `#{sfile(@store_into_this_file)}`."
          i = File.read(@store_into_this_file).strip
        else
          opnn
          e 'No entry could be found at non-existing '\
            'file `'+sfile(@store_into_this_file)+'`.'
        end
      when *ALPHABET.map(&:upcase)
        i = A # ← i will now be e. g. 01.10.2018
        # ================================================================= #
        # Next, we add the difference to this string.
        # ================================================================= #
        n_difference = ALPHABET.index(first.downcase)
        i = Time.parse(i) + ONE_DAY * n_difference
        i = dd_mm_yyyy(i)  
      end
    end
  end
  if i.is_a?(Array) and i.size == 1
    i = i.first
  end
  case i # case tag
  when *ARRAY_SHORTCUTS_FOR_THE_DAY_AFTER_TOMORROW
    i = Time.now + ONE_DAY + ONE_DAY
    i = return_dd_mm_yyyy(i)
  when *ARRAY_SHORTCUTS_FOR_TOMORROW
    i = Time.now + ONE_DAY
    i = return_dd_mm_yyyy(i)
  end
  # ======================================================================= #
  # We require an Array past this point:
  # ======================================================================= #
  i = [i].compact unless i.is_a? Array
  i.flatten!
  i.map! {|line|
    line = remove_leading_weekdays(line)
    case line
    when *ARRAY_SHORTCUTS_FOR_TOMORROW
      line = Time.now + ONE_DAY # ← Add one day.
      line = return_dd_mm_yyyy(line)
    when 'today','heute'
      line = return_dd_mm_yyyy(Time.now)
    end
    if line.end_with? ','
      line = line.dup if line.frozen?
      line.chop!
    end
    # ===================================================================== #
    # Check for a proper date, which is in the format dd.mm.yyyy.
    # ===================================================================== #
    if line =~ /^\d{1,2}\.\d{1,2}\.\d{4}$/
    else
      if line.count('.') == 1
        line = line.dup if line.frozen?
        line << '.'+current_year?
      end
    end
    line
  }
  @use_these_dates = i
end

#show_helpObject

#

show_help (help tag)

Invoke this method like so:

conflict --help
#


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/help.rb', line 19

def show_help
  e
  e "#{rev}This class can report all study-related lectures on "\
    "the given (input) date."
  e
  e "The date must be in the format dd.mm.yyyy, such as #{sfancy('01.10.2018')}" 
  e
  e '  conflict <DD.MM.YYYY>          # example: conflict 11.10.2018'
  e
  e '  conflict --lva-dates-of=301246 # show the lva-dates of lecture id 301246'
  e '                                 # ^^^ this is, sort of, a batch-variant'
  e
  e "  conflict A                     # show the courses on day #{sfancy(A)}"
  e '  conflict B                     # show the courses on day +1 after '+sfancy(A)
  e '  conflict def                   # simply repeat the last day '\
    'that was used before'
  e
  e 'Do note that for the last example (conflict def) to work, at the least'
  e 'one other date has to have been used before.'
  e
  e '  --show-raw                     # show some debug information (rarely needed)'
  e
  e 'You can also input a range separated via "-", such as in:'
  e
  e '  conflict 11.10.2020-11.11.2020'
  e
  e 'This would specify a total of 5 consecutive days.'
  e
end

#show_lva_dates_of_this_lecture(i) ⇒ Object

#

show_lva_dates_of_this_lecture

This method will report all LVA-dates of the given lecture at hand.

#


350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 350

def show_lva_dates_of_this_lecture(i)
  entries = @dataset.select {|name_of_the_lecture, inner_dataset|
    name_of_the_lecture.include? i
  }
  if entries.size > 1
    e 'More than one entry. Need to decide what to do with that.'
    e 'Proposing to just return the first entry. Acceptable? '\
      'Consider later (July 2018)'
  else
    name = entries.keys.first
    e 'Showing all lva-dates of the lecture `'+royalblue(name)+'` next:'
    hash = entries[name]
    lva_dates = hash['lva_dates']
    if lva_dates
      lva_dates.each {|lva_date|
        lva_date = remove_weekday_name(lva_date).strip
        lva_date = extract_dd_mm_yyyy(lva_date)
        prepare_dataset_and_then_report_for_this_date(lva_date)
      }
    else
      e 'No lva_dates: entry appears to be '\
        'registered for `'+royalblue(name)+'`.'
    end
  end
  exit
end

#show_raw_data?Boolean Also known as: show_raw?, debug?

#

show_raw_data?

#

Returns:

  • (Boolean)


42
43
44
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/misc.rb', line 42

def show_raw_data?
  @show_raw_data
end

#store_this_date_into_a_local_fileObject

#

store_this_date_into_a_local_file

This method will store the date used, aka the dd.mm.yyyy format, into a local file.

#


323
324
325
326
327
328
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 323

def store_this_date_into_a_local_file
  what = use_which_date?
  what = what.first if what.is_a? Array
  into = @store_into_this_file
  write_what_into(what, into)
end

#this_exam_happens_on_that_day?(i) ⇒ Boolean

#

this_exam_happens_on_that_day?

#

Returns:

  • (Boolean)


307
308
309
310
311
312
313
314
315
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 307

def this_exam_happens_on_that_day?(i)
  result = false
  unless @array_we_have_registered_for_these_exams_on_that_day.empty?
    @array_we_have_registered_for_these_exams_on_that_day.each {|a, b|
      result = true if a.include? i
    }
  end
  result
end

#use_these_dates?Boolean Also known as: main_day?, interesting_day?, use_this_date?, use_which_date?

#

use_this_date?

#

Returns:

  • (Boolean)


119
120
121
# File 'lib/studium/utility_scripts/show_conflicting_lva_lectures/show_conflicting_lva_lectures.rb', line 119

def use_these_dates?
  @use_these_dates
end