Class: Studium::Exams::UpcomingExams

Inherits:
Base
  • Object
show all
Defined in:
lib/studium/exams/upcoming_exams/upcoming_exams.rb

Overview

Studium::Exams::UpcomingExams

Constant Summary

Constants inherited from Base

Base::COMMON_YEAR_DAYS_IN_MONTH, Base::LEFT_PADDING, Base::NAMESPACE, Base::N_CHARACTERS_PER_LINE

Constants included from Colours

Colours::COLOURS

Class Method Summary collapse

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, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #chmod, #cliner, #colour_for_ects_points, #colourize_percentage, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #course_filter, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #current_semester?, #datum?, #day_month_year, #debug?, #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?, #does_this_line_include_an_english_weekday?, #does_this_line_start_with_a_german_weekday?, #e, #ecomment, #editor?, #ee, #egrey, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_that_a_base_directory_exists_for_this_file, #ensure_that_the_log_directory_exists, #eparse, #esystem, #etomato, #exit_program, #extract_dd_mm_yyyy, #fetch_this_curriculum, #file_important_exams?, #file_lecture_information?, #file_passed_exams_per_month, #file_read_with_proper_encoding, #filter_away_already_answered_questions, #filter_away_invalid_questions, #filter_for_all_passed_exams, #find_corresponding_exam_topic, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #german_weekend_for?, #german_yes_or_no, #has_a_bachelor_and_a_master_curriculum?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_lva_dates_registered?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #infer_the_namespace, #initialize_the_internal_hash, #internal_hash?, #is_a_master_lecture?, #is_a_registered_curriculum?, #is_a_weekday?, #is_connected_to_the_www?, #is_german_weekday?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_registered_exam_topic?, #is_this_a_valid_html_colour?, #is_this_day_today?, #is_this_lecture_a_practical_course?, #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, #left_arrow?, #load_yaml_dataset, #map_input_to_this_curriculum_filename, #move_file, #n_days_difference_from_today_to_this_day, #n_seconds_to_n_days, #namespace?, #no_ext_name, #no_file_exists_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_browser, #open_in_editor, #opne, #opnerev, #opnn, #padded_current_month?, #parse_dd_mm_yyyy, #parse_this_line_for_date_entry, #path_to_exam_topic?, #project_yaml_directory?, #rds, #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, #require_open_uri, #reset_the_internal_state, #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, #right_arrow?, #rinstall2, #roebe_exam_directory?, #roebe_path_to_file_lecture_information?, #ruby_src_dir_at_home?, #sanitize_this_topic, #sanitize_url, #select_for_prüfungsimmanente_LVs, #select_lectures_with_this_key, #set_be_verbose, #set_this_cd_alias_to, #set_xorg_buffer, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #silently_open_in_browser, #simp, #sort_these_lecture_names_by_time, #spacer, #studium_log_dir?, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_html_templates, #try_to_require_the_open_gem, #try_to_require_the_rcfiles, #try_to_require_the_verbose_truth_gem, #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, #yaml_dir?, #yellowrev, #yes_or_no

Methods included from RunmodeModule

#commandline?, #runmode?, #set_commandline_mode, #set_runmode, #set_www_mode, #www_mode?

Methods included from CommandlineArgumentsModule

#commandline_arguments?, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_non_hyphen_argument?, #reset_the_commandline_arguments, #set_commandline_arguments, #set_first_argument

Methods included from HtmlColoursModule

#aquamarine, #blanchedalmond, #brown, #cadetblue, #chocolate, #coral, #cornflowerblue, #crimson, #cyan, #darkblue, #darkcyan, #darkgoldenrod, #darkgreen, #darkkhaki, #darkolivegreen, #darkorange, #darkred, #darkseagreen, #darkslateblue, #darkslategray, #darkturquoise, #deepskyblue, #firebrick, #forestgreen, #gold, #goldenrod, #green, #grey, #indianred, #khaki, #lavender, #lawngreen, #lightblue, #lightcoral, #lightgreen, #lightred, #lightseagreen, #lightskyblue, #lightslategray, #lightslategrey, #lime, #limegreen, #mediumaquamarine, #mediumblue, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mediumvioletred, #mintcream, #moccasin, #oldlace, #olive, #olivedrab, #orange, #orangered, #orchid, #palegoldenrod, #palegreen, #paleturquoise, #palevioletred, #peru, #plum, #powderblue, #red, #rosybrown, #royalblue, #saddlebrown, #salmon, #sandybrown, #seagreen, #sienna, #silver, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #tan, #teal, #thistle, #tomato, #turquoise, #violet, #whitesmoke, #yellow, #yellowgreen

Methods included from Colours

#bold_blue, #bold_red, #bold_yellow, cadetblue, #cadetblue, #chartreuse, #coral, coral, #cornflowerblue, cornflowerblue, crimson, #cyan, cyan, darkgoldenrod, #darkgoldenrod, #darkgray, darkgreen, darkolivegreen, darkseagreen, #darkslateblue, darkslateblue, #darkslategray, darkslategray, #darkturquoise, darkturquoise, #deepskyblue, deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #erev, #ewarn, #forestgreen, forestgreen, gold, #goldenrod, goldenrod, #grey, grey, indianred, #indianred, khaki, #khaki, lawngreen, #lawngreen, lightblue, lightgreen, lightsalmon, #lightseagreen, lightseagreen, lightskyblue, #lightskyblue, #lightslategray, lightslategray, #lightsteelblue, lime, #lime, limegreen, #limegreen, #mediumaquamarine, mediumaquamarine, #mediumorchid, #mediumpurple, mediumpurple, #mediumseagreen, mediumseagreen, #mediumslateblue, mediumslateblue, #mediumspringgreen, mediumspringgreen, #mediumturquoise, mediumturquoise, #oldlace, olive, #olive, olivedrab, #olivedrab, orange, orangered, #orchid, orchid, palegreen, #palegreen, paleturquoise, #paleturquoise, palevioletred, #papayawhip, peru, #peru, plum, #plum, #powderblue, powderblue, rev, #rev?, royalblue, saddlebrown, #saddlebrown, #sandybrown, sandybrown, sdir, #sdir, seagreen, #seagreen, sfancy, #sfancy, sfile, #sfile, #simp, simp, #skyblue, skyblue, slateblue, #slategray, slategray, springgreen, #springgreen, #steelblue, steelblue, #swarn, swarn, #tan, tan, teal, #teal, #tomato, tomato, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow, yellowgreen, #yellowgreen

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ UpcomingExams

#

initialize

#


24
25
26
27
28
29
30
31
32
33
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 24

def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Studium::Exams::UpcomingExams[]

#


547
548
549
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 547

def self.[](i = ARGV)
  new(i)
end

.in_this_curriculum(i = :bachelor_agrarwissenschaften) ⇒ Object

#

Studium::Exams::UpcomingExams.in_this_curriculum

This method will yield all upcoming exams for a specific curriculum. For instance, all upcoming exams for the Bachelorcurriculum Agrarwissenschaften.

What exactly is an “upcoming exam”? Obviously this requires information about the time/date, so a future day where the exam will be held.

Usage example:

Studium::Exams::UpcomingExams.in_this_curriculum(:bachelor_agrarwissenschaften)
Studium::Exams::UpcomingExams.in_this_curriculum(:bachelor_lbt)
#


500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 500

def self.in_this_curriculum(
    i = :bachelor_agrarwissenschaften
  )
  dataset = YAML.load_file(Studium.file_lecture_information)
  # ======================================================================= #
  # First, select only those entries that actually have an upcoming
  # exam registered:
  # ======================================================================= #
  all_lectures_with_an_exams_entry = dataset.select {|a, b|
    exams = b['exams']
    exams and !exams.empty?
  }
  we_seek_this_curriculum_id = Studium.to_curriculum_id(i)
  all_lectures_with_an_exams_entry_for_this_curriculum = all_lectures_with_an_exams_entry.select {|a, b|
    curricula = b['curricula'] # This will now be an Array such as ['033225', '033227']
    curricula.include?(we_seek_this_curriculum_id)
  }
  # ======================================================================= #
  # Last but not least, we have to compare this with the current day.
  # ======================================================================= #
  today = ::Time.now
  regex_for_the_exam_day = /(\d{2}\.\d{2}\.\d{4})/ # Match towards e. g. "30.01.2023".
  all_lectures_with_an_upcoming_exams_entry_for_this_curriculum = all_lectures_with_an_exams_entry_for_this_curriculum.select {|a, b|
    exams = b['exams'].map {|entry|
      # =================================================================== #
      # The entry may be like this:
      #
      #   "Dienstag   30.01.2023, 08:30-09:30, Ort: HS TÜWI01 TÜWI-U1/02"
      #
      # =================================================================== #
      if (entry =~ regex_for_the_exam_day)
        ::Time.parse($1.to_s.dup)
      else
        nil
      end
    }
    exams.compact!
    exams.any? {|inner_entry|
      inner_entry > today
    } # This means an upcoming exam.
  }
  return all_lectures_with_an_upcoming_exams_entry_for_this_curriculum
end

.open_relevant_filesObject

#

Studium::Exams::UpcomingExams.open_relevant_files

#


461
462
463
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 461

def self.open_relevant_files
  ::Studium.open_important_exams
end

Instance Method Details

#check_for_duplicatesObject

#

check_for_duplicates

#


239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 239

def check_for_duplicates
  hash = {}
  hash.default = 0
  @dataset_from_the_file_important_exams.each {|entry|
    splitted = entry.split('|')
    # ===================================================================== #
    # The name of the lecture is only the first part of the above variable.
    # ===================================================================== #
    name_of_the_lecture = splitted.first.strip
    hash[name_of_the_lecture] += 1
  }
  # ======================================================================= #
  # Next we will check for duplicates. If found, we will report them.
  # ======================================================================= #
  try_to_report_duplicate_entries_in_this_hash(hash)
end

#check_for_entries_that_were_already_successfully_completed_and_report_theseObject

#

check_for_entries_that_were_already_successfully_completed_and_report_these

#


211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 211

def check_for_entries_that_were_already_successfully_completed_and_report_these
  dataset_from_the_file_lecture_information = ::Studium.return_dataset_from_the_file_lecture_information
  @dataset_from_the_file_important_exams.each {|this_lecture| # This variable will look like this: "134.202 Biomembranes"
    if dataset_from_the_file_lecture_information.has_key? this_lecture
      # Ok if it is there then we check if it has been completed already.
      pointer = dataset_from_the_file_lecture_information[this_lecture]
      already_solved = pointer[:already_solved]
      is_an_outdated_lecture = pointer[:outdated_lecture]
      if (is_an_outdated_lecture == true)
        e 'Warning! Outdated lecture ('+tomato(this_lecture)+
          '). Remove it from the'
        e 'file '+sfile('important_exams.yml')
      elsif (already_solved == true)
        e tomato('The course ')+
          steelblue(this_lecture)+
          tomato(' has already been solved.')
        e tomato('It can be removed from the file ')+
          sfile('important_exams.yml')+
          tomato('.')
      end
    else
    end
  }
end

#check_whether_the_entries_in_the_file_important_exams_are_correctObject

#

check_whether_the_entries_in_the_file_important_exams_are_correct (check tag)

Invocation example:

timetable --check
#


399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 399

def check_whether_the_entries_in_the_file_important_exams_are_correct
  dataset_from_the_file_lecture_information =
    Studium.return_sanitized_dataset_from_the_file_lecture_information
  everything_is_ok = true
  _ = prepare_and_then_return_main_dataset
  _.each {|line|
    first = line
    first = first.first if first.respond_to?(:first)
    first = first.squeeze(' ').strip
    if dataset_from_the_file_lecture_information.has_key?(first)
      # Then all is fine
    else
      everything_is_ok = false
      opne 'The lecture '+sfancy(first)+' is not registered '\
           'in the file '+sfancy('lecture_information.yml')
    end
  }
  if everything_is_ok
    opne 'Everything is fine - the entries in the file '
    opne sfile('lecture_information.yml')+' all appear to be correct.'
  end
end

#dataset?Boolean

#

dataset?

#

Returns:

  • (Boolean)


468
469
470
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 468

def dataset?
  @dataset
end

#do_not_exitObject

#

do_not_exit

#


278
279
280
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 278

def do_not_exit
  @exit_on_problems = false
end

#filter_away_all_but_these_months(i) ⇒ Object

#

filter_away_all_but_these_months

This method can be used to filter away all but the given input arguments months, such as ‘September’.

Invocation example:

upcoming_exams --September
#


376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 376

def filter_away_all_but_these_months(i)
  i = i.delete('-')
  i.sub!(/month=/,'') if i.include? 'month='
  i = return_month_fitting_to_this_input(i)
  i = i.to_i # Don't want any '-' characters.
  @dataset.select! {|a,b|
    exams = b['exams']
    if exams.is_a? Array
      exams = exams.first
    end
    exams = remove_german_weekdays(exams).strip.delete(',')
    exams.split('.')[1].to_i == i
  }
end

#filter_away_unimportant_examsObject

#

filter_away_unimportant_exams

#


321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 321

def filter_away_unimportant_exams
  @dataset.select! {|a, b|
    unless @dataset.has_key?(a)
      opne 'The key '+sfancy(a.strip)+' is not registered '\
           'in the file lecture_information.yml'
      opne 'This is presently not allowed. '+
            yellow('Exiting now.')
      opne 'The file that should include this lecture is `'+
            sfile(
              File.basename(main_file?)
            )+rev+'`.'
      exit
    end
    @dataset_from_the_file_important_exams.include?(a)
  }
end

#main_file?Boolean Also known as: important_exams?

#

main_file?

This query-method will refer to the file called “studium/yaml/important_exams.yml”.

#

Returns:

  • (Boolean)


428
429
430
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 428

def main_file?
  Studium.file_important_exams?
end
#

menu (menu tag)

#


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
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 87

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i
    # ===================================================================== #
    # === timetable --September
    # === timetable --month=September
    # === timetable --July
    # ===================================================================== #
    when /^-?-?(month=)?August$/i,
         /^-?-?(month=)?September$/i,
         /^-?-?(month=)?November$/i,
         /^-?-?(month=)?October$/i,
         /^-?-?(month=)?December$/i,
         /^-?-?(month=)?January$/i,
         /^-?-?(month=)?February$/i,
         /^-?-?(month=)?March$/i,
         /^-?-?(month=)?April$/i,
         /^-?-?(month=)?May$/i,
         /^-?-?(month=)?June$/i,
         /^-?-?(month=)?July$/i
      # =================================================================== #
      # Next, we have to filter away all entries but the specific month.
      # =================================================================== #
      filter_away_all_but_these_months(i) # Do an in-place filter here.
    # ===================================================================== #
    # === timetable --check
    # ===================================================================== #
    when /^-?-?check$/i
      check_whether_the_entries_in_the_file_important_exams_are_correct
      exit
    # ===================================================================== #
    # === timetable --master
    # ===================================================================== #
    when /^-?-?master$/i
      _ = main_dataset?.select {|name_of_the_lecture, b|
        is_a_master_lecture?(name_of_the_lecture)
      }
      set_main_dataset(_)
    # ===================================================================== #
    # === timetable --do-not-exit
    # ===================================================================== #
    when /^-?-?do(-|_)?not(-|_)?exit$/i
      do_not_exit
    # ===================================================================== #
    # === timetable --help
    # ===================================================================== #
    when /-?-?help$/i
      show_help
      exit
    # ===================================================================== #
    # === timetable --open
    # ===================================================================== #
    when /open$/i
      open_all_important_files
      exit
    end
  end
end

#notify_the_user_that_this_lecture_has_no_associated_remote_url(name_of_the_lecture_that_we_wish_to_display) ⇒ Object

#

notify_the_user_that_this_lecture_has_no_associated_remote_url

#


194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 194

def notify_the_user_that_this_lecture_has_no_associated_remote_url(
    name_of_the_lecture_that_we_wish_to_display
  )
  opne 'It seems as if "'+
        sfancy(name_of_the_lecture_that_we_wish_to_display)+
        '" does not have an associated'
  opne "remote URL. Please add this to the file "\
       "#{sfile('university_menu.rb')}"
  if @exit_on_problems
    opne 'Exiting now. (--do-not-exit can be bypassed to NOT exit)'
    exit
  end
end

#notify_the_user_which_file_is_to_be_usedObject

#

notify_the_user_which_file_is_to_be_used

#


450
451
452
453
454
455
456
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 450

def notify_the_user_which_file_is_to_be_used
  e
  opne 'Using the dataset from the file'
  e
  e "  #{sfile(main_file?)}"
  e
end

#open_all_important_filesObject

#

open_all_important_files (open tag)

It will open the file on my home system, rather than the one that is inside the distributed studium-gem.

To invoke this, do:

timetable --open
#


443
444
445
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 443

def open_all_important_files
  ::Studium.open_important_exams
end

#prepare_and_then_return_main_datasetObject

#

prepare_and_then_return_main_dataset

#


285
286
287
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 285

def prepare_and_then_return_main_dataset
  return read_in_the_dataset_from_the_file_important_exams
end

#read_in_the_dataset_from_the_file_important_exams(use_this_file = Studium.file_important_exams?) ⇒ Object

#

read_in_the_dataset_from_the_file_important_exams

#


292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 292

def read_in_the_dataset_from_the_file_important_exams(
    use_this_file = Studium.file_important_exams?
  )
  # ======================================================================= #
  # === @dataset_from_the_file_important_exams
  #
  # Assign the dataset from the file important_exams.yml next.
  # ======================================================================= #
  @dataset_from_the_file_important_exams =
    readlines_with_the_default_encoding(use_this_file).reject {|line|
      line.strip.empty? or line.strip.start_with?('#')
    }.map {|inner_line| # Process it a bit.
      inner_line = inner_line.strip.squeeze(' ').dup
      if inner_line.start_with? '- '
        inner_line.delete_prefix!('- ')
        inner_line.delete!('"')
      end
      if inner_line.include? ' #'
        inner_line = inner_line.split(' #').first.strip
      end
      inner_line.strip!
      inner_line
    }
  return @dataset_from_the_file_important_exams
end

#report(i = @dataset) ⇒ Object Also known as: report_the_lectures_that_will_be_used

#

report

#


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
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 153

def report(
    i = @dataset
  )
  if i and !i.empty?
    opne tomato("#{i.size} upcoming exams ")+
         grey("were found. Displaying these upcoming exams next.")
    e
  end
  i.each {|name_of_the_lecture, inner_hash|
    exams = inner_hash['exams']
    # ===================================================================== #
    # === :homepage
    #
    # We also want to use the remote_url, so add it next. However had, for
    # the time being, we require that this is registered in the project
    # BeautifulUrl. And if it is not, then we will report this as an error.
    # ===================================================================== #
    if inner_hash.has_key? :homepage
      use_this_remote_url = inner_hash[:homepage] # Get a handler first.
      if use_this_remote_url.is_a? Array
        use_this_remote_url = use_this_remote_url.first
      end
    else
      notify_the_user_that_this_lecture_has_no_associated_remote_url(
        name_of_the_lecture
      )
    end
    # ===================================================================== #
    # Tell the user on which lecture we are working right now.
    # ===================================================================== #
    _ = hh_mm_ss_dd_mm_yyyy(exams).split('-').reverse.join(', ')
    e grey('Working on ')+
      "#{steelblue(name_of_the_lecture)}"
    e "  #{steelblue(rarrow?)} #{orange(use_this_remote_url)} "
    e "  #{grey('Exam at: ')}#{tomato(_)}"
  }
end

#resetObject

#

reset (reset tag)

#


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 38

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @exit_on_problems
  # ======================================================================= #
  @exit_on_problems = false
  # ======================================================================= #
  # === @dataset
  #
  # This variable will eventually hold the lectures that we wish
  # to display. It taps into the file "lecture_information.yml"
  # originally.
  # ======================================================================= #
  @dataset = return_lectures_with_at_the_least_one_upcoming_exam
  read_in_the_dataset_from_the_file_important_exams
end

#runObject

#

run (run tag)

#


475
476
477
478
479
480
481
482
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 475

def run
  menu
  notify_the_user_which_file_is_to_be_used
  check_for_duplicates
  check_for_entries_that_were_already_successfully_completed_and_report_these
  sanitize_the_dataset
  report
end

#sanitize_the_datasetObject

#

sanitize_the_dataset

#


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 341

def sanitize_the_dataset
  # ======================================================================= #
  # First, filter away the unimportant exams.
  # ======================================================================= #
  filter_away_unimportant_exams
  _ = @dataset.map {|a, inner_hash|
    exams = inner_hash['exams']
    if exams.is_a? Array
      exams = exams.first
    end
    exams.strip!
    exams.squeeze!(' ')
    exams = remove_german_weekdays(exams)
    if exams.include? '-'
      exams = exams.split('-').first
    end
    inner_hash['exams'] = Time.parse(exams)
    [a, inner_hash]
  }
  _ = _.sort_by {|a,b| b['exams'] }
  _ = Hash[_]
  @dataset = _
end

#show_helpObject

#

show_help (help tag)

This method is to be used from the commandline. The user will be told how to use certain flags in combination with this class.

Invocation example:

timetable --help
#


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 67

def show_help
  e; opnn { :no_trailing_character }; e
  e
  e 'The following commandline-options are available:'
  e
  e '  '+steelblue('--check')+'           # check the format and validity '\
    'of the file important_exams.yml'
  e '  '+steelblue('--do-not-exit')+'     # do not exit if there is no registration '\
    'in the project beautiful_url.'
  e '  '+steelblue('--master')+'          # show only upcoming master-exams.'
  e '  '+steelblue('--month=September')+' # show only exams in that month'
  e
  e "Additionally you can pass in #{orange('--open')} to "\
    "open the yaml file."
  e
end

#try_to_report_duplicate_entries_in_this_hash(hash) ⇒ Object

#

try_to_report_duplicate_entries_in_this_hash

This method will try to find duplicate entries in the given Hash.

#


261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/studium/exams/upcoming_exams/upcoming_exams.rb', line 261

def try_to_report_duplicate_entries_in_this_hash(
    hash
  )
  potential_duplicates = hash.select {|key, value| value > 1 }
  unless potential_duplicates.empty?
    opne "The file #{sfile(main_file?)} has at the "\
         "least one duplicate entry."
    potential_duplicates.each {|key, value|
      opne "A duplicate entry was found, called: `#{sfancy(key)}#{rev}`"
      opne 'The file that holds this entry is `'+sfile(main_file?)+rev+'`.'
    }
  end
end