Class: Studium::Base

Inherits:
Object
  • Object
show all
Includes:
Colours, CommandlineArgumentsModule, HtmlColoursModule, RunmodeModule
Defined in:
lib/studium/base/base.rb

Overview

Studium::Base

Direct Known Subclasses

Afterburn, AskQuestionFromAlias, AskQuestionFromGroupedThemes, AskQuestionFromLastTopic, AskRandomQuestion, AttributeLectureToCurriculum, AttributeLecturesToUniversity, AudioStats, AutoStud, Autogeneration, AutopurgeThisLectureDate, AverageGradeOfThisCurriculum, Studium::BOKU::ShowThreePillarsOfTheseLectures, Studium::BOKU::ThreePillars, BlockedCourses, BokuEctsSplitter, Calendar, CheckCurriculumForCorrectSeparationOfBachelorAndMaster, CheckDescriptionOfTheseLectures, CheckForAllExamTopicsBeingRegistered, CheckForCorrectThemesOfEachCourse, CheckForExistingDescriptionOfThisLecture, CheckImportantExams, CheckTheLectureInformationFile, Commandline, CorrectAllDatesInTheFileLectureInformation, CourseRegistrations, Courses, Create::WebpageOfUniversity, CreateDatabase, CreatePdfFileForThisExamTopic, CurrentLecturesBelongingToBothBachelorAndMasterCurriculum, CurrentlyParticipatingInTheseLectures, Curricula::CurriculumAsString, Curricula::DetermineElectiveCoursesInThisCurriculum, Curricula::DisplayBachelorCurricula, Curricula::HandleCurricula, Curricula::Mitteilungsblätter, Curricula::Modules::DisplayOnTheCommandline, CurriculaFromThisWebsite, Curriculum, CurriculumModuleDisplayer, CustomExamResultsParser, DateSanitizer, DetermineCurricula, DisplayLectureUrl, ECTS::SearchFor_nECTS, EctsPerUniversity, EctsScanner, EctsToUniversityParser, Exams::AskExamFromTheUpcomingExamsPool, Exams::AskExamTopicQuestion, Exams::AskQuestionFromAnyOfTheStillMissingLectures, Exams::AverageGrade, Exams::CreateCsvPassedExamsFile, Exams::Cycle, Exams::DesignateTenRandomExamTopics, Exams::Exam, Exams::ExamBubble, Exams::ExamQuestion, Exams::ExamRegistrationAt, Exams::ExamStatisticsFromThisFile, Exams::ExamTopics, Exams::LastExams, Exams::LecturesWithoutExamEntry, Exams::MandatoryContinuousAssessment, Exams::NextExam, Exams::NextExams, Exams::NotCompleted, Exams::OpenExamAssociatedUrl, Exams::OpenLastExamQuestionAskedFile, Exams::PublishMyExams, Exams::PushSolvedQuestionsOnTop, Exams::QuestionAnswer, Exams::QuestionsSolvedFromDayToDay, Exams::RepeatLastQuestion, Exams::ShowExamsFor, Exams::ShowThemes, Exams::Solved, Exams::ThisWeek, Exams::Timetable, Exams::UpcomingExams, Exams::UpcomingExamsAtTheBoku, Exams::UpcomingExamsDataset, Exams::UpcomingRegisteredExams, Exams::UploadExamTopics, ExamsPerMonth, ExpandTimeRange, FindDuplicateLectures, FinishedExamsAtThisUniversity, FixExamDates, ForeignLanguagePercentage, GUI::UniversalWidgets::EctsPerUniversity, GUI::UniversalWidgets::ShowUpcomingExams, GenerateRegex, GenerateSpreadsheet, Holidays, HomepageOfTheseCourses, IndividualResolvePracticalCoursesDateConflicts, Jobs, LastEntryIsCurriculum, LecturesAttributedToUniversities, Log::StoreLastQuestionAskedIntoFile, LvaDatesOfTheImportantCourses, LvaNummer, MandatoryLecturesInThisMonth, Moodle, MoveAllUnsolvedExamQuestionsToTheTopOfTheFile, MoveTheLastExamQuestionToTheTopOfTheFile, NEctsInTheseLectures, NExamsInTheseTopics, NameOfThisLvaId, NewStud, NextWeek, NotYetRegistered, OpenLastExamQuestionUrlLinkViaTheBrowser, ParseRemoteLecture, PassedEctsPerYear, PassedPrüfungsimmanenteCourses, PreparatoryMeetings, PrepareIndividualCurriculum, Priority, PriorityPoints, RandomCurriculumCreator, ReportOutdatedTimetableEntries, ReportTotalAmountOfQuestionsAndAnswersFor, ReportWhetherThisLectureIsRegisteredInTheFileLectureInformation, ResolvePracticalCoursesDateConflicts, ReturnNEctsFromThisUrl, SanitizeLectureInformation, ScrapeRemoteUniversityUrl, SemesterContainer, SemesterScheduleCreator, Semesterplaner, SetAliasesBasedOnThisFile, ShowAllPassedExamsOfThisUniversity, ShowAllPassedMasterLectures, ShowAllSteopLectures, ShowBacklogOfExams, ShowCompletedEctsInAllCurricula, ShowConflictingLvaLectures, ShowDescriptionsOfLecturesBelongingToThisModule, ShowLecturers, ShowLectures, ShowLecturesFittingToThisLanguage, ShowLecturesFittingToThisTheme, ShowLecturesOfThisCurriculum, ShowLecturesOfThisCurriculumId, ShowLecturesOnTheCommandline, ShowLecturesOnThisDay, ShowLvaDatesOfThisLecture, ShowMixedBachelorMasterCourses, ShowOutdatedLvaDates, ShowPassedCreditsPerCurriculum, ShowPassedExamsHavingThisGrade, ShowSolvedEnglishLectures, ShowSolvedPercentageAmongTheRegisteredCurricula, ShowUpcomingExams, SimpleTotalEctsPoints, SolveAllQuestionsFromThisTopic, SolvedEcts, SolvedEctsPerUniversity, SortedIndividualCurricula, Statistics::BestExamMonths, Statistics::CurriculumComparer, Statistics::DetermineExamStatisticsFromThisFile, Statistics::ExamTopicsThatAreAboutToBeCompleted, Statistics::MaxStats, Statistics::NewExamsQuestionsPerYear, Statistics::ReportHowManyEctsPointsPerCurriculumWereCompleted, Statistics::ReportHowManyExamQuestionsWereAnswered, Statistics::ShowWhichCoursesAreInABachelorOrMasterCurriculumRespectively, Statistics::TopStats, SteopLecturesInThisCurriculum, SteopLvaDates, StillMissing, Studienkennzahl, StudiumSkeleton, Stundenplan, SumOfEcts, SyncStudiumRelevantEntriesOneLevelDownwards, Ufind, UniversityCourse, UnsolveAllQuestionsFromThisTopic, UpcomingMandatoryPresenceCourses, VideoLectureDownloader, WeekParser, WeekdayParser, WeeklySchedule, Wochenplanung

Constant Summary collapse

NAMESPACE =
#

Studium::Base::NAMESPACE

#
inspect
N_CHARACTERS_PER_LINE =
#

Studium::Base::N_CHARACTERS_PER_LINE

If an answer exceeds the following threshold value, then we will chop some bits off of it. The reason why we have defined this here in class Base is because at the least two other classes that are part of the Exam namespace, require this.

#
78
LEFT_PADDING =
#

Studium::Base::LEFT_PADDING

The default padding (for showing the answer to an exam question) is 4 spaces since as of July 2020. In November 2020 2 spaces are now tried.

#
' ' * 2
COMMON_YEAR_DAYS_IN_MONTH =
#

Studium::Base::COMMON_YEAR_DAYS_IN_MONTH

This constant has the days per month, for the whole year.

It will not honour leap years properly, though.

#
[
  nil,
  31,
  28,
  31,
  30,
  31,
  30,
  31,
  31,
  30,
  31,
  30,
  31
]

Constants included from Colours

Colours::COLOURS

Instance Method Summary collapse

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, sfile, #sfile, 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

Instance Method Details

#add_proper_year_entry_to_this_line(line) ⇒ Object

#

add_proper_year_entry_to_this_line

This method will add a proper year entry to a line. It will either append a year entry - or, which may be more useful, try to insert the year-entry into a position that fits. The latter will make use of a regex.

A test string for the latter is the following:

"Dienstag   02.10. 11:30-13:00 UZA2 Hörsaal 5 Raum 2Z202 2.OG"
#


1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
# File 'lib/studium/base/base.rb', line 1928

def add_proper_year_entry_to_this_line(line)
  result = line.dup
  current_year = Time.now.year
  use_this_regex = # See: https://rubular.com/r/xV0yNSYhWW
    /^(.+)(\d{2}\.\d{1,2}\.) (\d{1,2}:\d{1,2}(-| )?\d{1,2}:\d{1,2})(.+)$/
  if result =~ use_this_regex
    result.sub!(use_this_regex, '\1\2'+current_year.to_s+', \3\5')
  else # this here is the simpler case
    result << current_year # This is the variant that will simply append.
  end
  result
end

#already_solved_this_lva_number?(i) ⇒ Boolean

#

already_solved_this_lva_number?

#

Returns:

  • (Boolean)


2447
2448
2449
# File 'lib/studium/base/base.rb', line 2447

def already_solved_this_lva_number?(i)
  Studium.already_solved_this_lva_number?(i)
end

#append_what_into(what, into) ⇒ Object

#

append_what_into (append tag)

Use this method to save data into a specific file.

#


1361
1362
1363
# File 'lib/studium/base/base.rb', line 1361

def append_what_into(what, into)
  Studium.append_what_into(what, into)
end

#available_topics_as_short_nameObject Also known as: available_topics?, exam_topics?, return_all_exam_topics, available_exam_topics?

#

available_topics_as_short_name

#


2738
2739
2740
# File 'lib/studium/base/base.rb', line 2738

def available_topics_as_short_name
  ::Studium::Exams.all_topics_as_short_name.sort
end

#average_grade(i = :default, round_to = 2) ⇒ Object

#

average_grade

#


1199
1200
1201
1202
1203
1204
1205
# File 'lib/studium/base/base.rb', line 1199

def average_grade(
    i        = :default,
    round_to = 2 # ← Round to two numbers.
  )
  require 'studium/exams/average_grade/average_grade.rb'
  Studium.average_grade(i, round_to)
end

#bachelor_master_or_diploma(this_lecture, dataset = nil) ⇒ Object

#

bachelor_master_or_diploma

For a given solved lecture, we will determine whether it belongs to a Bachelor (B), Master (M) or Diploma (D) curriculum.

For the line:

13.05.2020 | 1.0 |  1.0 | 1 |   BOKU  |   M  |   SE  |   940003   | 2020S | Emerging Topics in RNA Biology (in Eng.)
      0       1      2    3      4        5

It would be at 5.

#


2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
# File 'lib/studium/base/base.rb', line 2597

def bachelor_master_or_diploma(
    this_lecture, dataset = nil
  )
  if dataset.nil? and File.exist? Studium.file_passed_exams_per_month
    dataset = File.readlines(Studium.file_passed_exams_per_month).reject {|line|
      line.strip.empty? or
      line.strip.start_with?('#')
    }
  end
  selection = dataset.select {|line|
    splitted = this_lecture.split(' ')
    lecture_id = splitted.first
    course_name = splitted[1..-1].join(' ').strip
    line.include?(lecture_id) and
    line.include?(course_name)
  }
  if selection.empty?
    '(unknown)'
  else
    selection = selection.first
    return selection.split('|')[5].strip 
  end
end

#be_silentObject Also known as: be_quiet

#

be_silent

#


761
762
763
# File 'lib/studium/base/base.rb', line 761

def be_silent
  @internal_hash[:be_verbose] = false
end

#be_verbose?Boolean

#

be_verbose?

#

Returns:

  • (Boolean)


455
456
457
# File 'lib/studium/base/base.rb', line 455

def be_verbose?
  @internal_hash[:be_verbose]
end

#beautiful_url(i) ⇒ Object Also known as: return_remote_URL

#

beautiful_url

This method can be used to “beautify” a remote URL, based on shorter input.

Until 10.12.2019 this method exclusively used BeautifulUrl.

Since as of 10.12.2019, this method will actually tap into Studium.return_url_from() if it is registered.

#


1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
# File 'lib/studium/base/base.rb', line 1856

def beautiful_url(i)
  unless Studium.respond_to? :is_this_url_registered?
    # ===================================================================== #
    # Enable support for that .rb file next.
    # ===================================================================== #
    require 'studium/toplevel_methods/return_remote_homepage_of_this_lecture.rb'
  end
  if Studium.is_this_url_registered?(i)
    i = Studium.return_url_from(i)
  else
    i = BeautifulUrl[i]
  end
  if i.is_a? Array
    i = i.first
  end
  return i
end

#change_directory(i = Dir.pwd) ⇒ Object Also known as: cd

#

change_directory

#


881
882
883
884
885
# File 'lib/studium/base/base.rb', line 881

def change_directory(
    i = Dir.pwd
  )
  FileUtils.chdir(i)
end

#cheering_personObject Also known as: cheering_person?, cheering_dude?

#

cheering_person

#


1257
1258
1259
# File 'lib/studium/base/base.rb', line 1257

def cheering_person
  '\o/'
end

#chmod(new_mode = 0644, which_file = 'LINKS.md') ⇒ Object

#

chmod

The second argument can also be an Array.

#


2832
2833
2834
2835
2836
2837
# File 'lib/studium/base/base.rb', line 2832

def chmod(
    new_mode   = 0644,
    which_file = 'LINKS.md'
  )
  FileUtils.chmod(new_mode, which_file)
end

#cliner(which_token_to_use = :default_token, use_this_colour = nil, &block) ⇒ Object

#

cliner (cliner tag)

This method can be used such as in the following example, if a specific colour is wanted:

cliner('*', :mediumaquamarine)
cliner { :unicode }
#


2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
# File 'lib/studium/base/base.rb', line 2000

def cliner(
    which_token_to_use = :default_token,
    use_this_colour    = nil,
    &block
  )
  if which_token_to_use.is_a? Hash # Treat Hashes specially.
    # ===================================================================== #
    # === :colours
    # ===================================================================== #
    if which_token_to_use.has_key? :colours
      use_this_colour = which_token_to_use.delete(:colours)
      which_token_to_use = :default_token
    # ===================================================================== #
    # === :colour
    # ===================================================================== #
    elsif which_token_to_use.has_key? :colour
      use_this_colour = which_token_to_use.delete(:colour)
      which_token_to_use = :default_token
    end
  end
  case which_token_to_use
  # ======================================================================= #
  # === :default_token
  # ======================================================================= #
  when :default_token
    which_token_to_use = '='
  end
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :unicode
    # ===================================================================== #
    when :unicode
      begin
        require 'roebe/toplevel_methods/unicode/unicode_block_elements.rb'
        which_token_to_use = Roebe.horizontal_double_bar.dup
      rescue LoadError; end
    else
      use_this_colour = :mediumaquamarine
    end
  end
  result = (which_token_to_use * 80)
  if use_this_colour.is_a? Symbol
    if use_this_colour.to_s.include?('konsole_') or
       is_this_colour_a_html_colour?(use_this_colour)
      unless use_this_colour.to_s.include? '_colour_'
        use_this_colour = use_this_colour.to_s
        use_this_colour.sub!(/_/,'_colour_')
      end
      result = COLOURS.send(use_this_colour, result) if COLOURS
    end
  end
  e result
end

#colour_for_ects_points(i = '') ⇒ Object Also known as: colourize_ects, colour_ects

#

colour_for_ects_points

#


1161
1162
1163
# File 'lib/studium/base/base.rb', line 1161

def colour_for_ects_points(i = '')
  ::Studium.colour_for_ects_points(i)
end

#colourize_percentage(i) ⇒ Object

#

colourize_percentage

This method should be used when we wish to display percentage values on the commandline.

#


1642
1643
1644
1645
# File 'lib/studium/base/base.rb', line 1642

def colourize_percentage(i)
  return seagreen(i) if use_colours? # Used to be cadetblue.
  return i
end

#convert_this_array_of_lectures_into_the_full_dataset(i) ⇒ Object

#

convert_this_array_of_lectures_into_the_full_dataset

The purpose of this method is to turn an Array that holds Strings such as “941111 Genetische Ressourcen von Nutzpflanzen” into the corresponding dataset.

This method will return a Hash if everything went fine.

#


823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
# File 'lib/studium/base/base.rb', line 823

def convert_this_array_of_lectures_into_the_full_dataset(i)
  if i.is_a? Array
    if Studium.main_dataset?.nil?
      Studium.initialize_main_dataset
    end
    _ = Studium.main_dataset?
    hash = {}
    i.map {|course_id_and_course_name|
      if _.has_key?(course_id_and_course_name)
        hash[course_id_and_course_name] = _[course_id_and_course_name]
      end
    }
    hash
  else
    raise 'This method only accepts an Array as input.'
  end
end

#copy(from, to) ⇒ Object Also known as: copy_file

#

copy (copy tag)

#


618
619
620
621
622
623
624
625
626
# File 'lib/studium/base/base.rb', line 618

def copy(from, to)
  if from.is_a? Array
    from.each {|entry|
      copy(entry, to)
    }
  else
    FileUtils.copy(from, to)
  end
end

#course_filter(dataset = dataset?, , filter_how = :BOKU) ⇒ Object

#

course_filter

This method is a generic filter over the dataset made available in the file lecture_information.yml.

#


3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
# File 'lib/studium/base/base.rb', line 3214

def course_filter(
    dataset    = dataset?,
    filter_how = :BOKU
  )
  act_on_this_entry = :university
  case filter_how
  # ======================================================================= #
  # === :winter
  # ======================================================================= #
  when :winter
    act_on_this_entry = :semester
  # ======================================================================= #
  # === :prüfungsimmanent
  # ======================================================================= #
  when :prüfungsimmanent
    act_on_this_entry = :type
  end
  return dataset.select {|name_of_the_course, inner_hash|
    case act_on_this_entry
    # ===================================================================== #
    # === :type
    # ===================================================================== #
    when :type
      case filter_how
      # =================================================================== #
      # === :prüfungsimmanent
      # =================================================================== #
      when :prüfungsimmanent
        _ = inner_hash[act_on_this_entry]
        is_prüfungsimmanent?(_)
      else
        false
      end
    # ===================================================================== #
    # === :semester
    # ===================================================================== #
    when :semester
      _ = inner_hash[act_on_this_entry]
      if _
        _.to_sym == filter_how # e. g. == :winter
      else
        e 'nil-entry for '+name_of_the_course+' - please fix this.'
      end
    # ===================================================================== #
    # === :university
    # ===================================================================== #
    when :university
      inner_hash[act_on_this_entry].to_sym == filter_how
    end
  }
end

#cprubyObject

#

cpruby

#


490
491
492
493
494
495
496
# File 'lib/studium/base/base.rb', line 490

def cpruby
  base_dir = ENV['USERS']
  base_dir = '/home' if base_dir.nil?
  path_to_setup_rb_file =
    "#{RUBY_SRC_DIR}roebe/lib/roebe/setup/setup.rb"
  copy(path_to_setup_rb_file, '.')
end

#create_directory(i) ⇒ Object Also known as: mkdir

#

create_directory

#


874
875
876
# File 'lib/studium/base/base.rb', line 874

def create_directory(i)
  FileUtils.mkdir_p(i)
end

#create_file(i) ⇒ Object Also known as: touch

#

create_file

#


860
861
862
# File 'lib/studium/base/base.rb', line 860

def create_file(i)
  FileUtils.touch(i)
end

#csv_file?Boolean

#

csv_file?

This method is only useful on my home setup.

#

Returns:

  • (Boolean)


2378
2379
2380
# File 'lib/studium/base/base.rb', line 2378

def csv_file?
  Studium.file_passed_exams_per_month
end

#current_month?Boolean Also known as: month?, return_current_month_as_a_number

#

current_month?

Show us the current month, as Integer. For example, for April, this method would return the number 4.

#

Returns:

  • (Boolean)


304
305
306
# File 'lib/studium/base/base.rb', line 304

def current_month?
  return ::Time.now.strftime('%m').to_i
end

#current_semester?Boolean

#

current_semester?

This method will either return the Symbol :summer or it will return the Symbol :winter. This will be based on the current time (today).

#

Returns:

  • (Boolean)


3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
# File 'lib/studium/base/base.rb', line 3018

def current_semester?
  today = ::Time.now
  # ======================================================================= #
  # Next we must determine whether we have the Range in winter or the
  # Range in summer.
  # ======================================================================= #
  current_year = current_year?.to_i
  next_year    = current_year+1
  winter_range = ( Date.parse('01.10.'+current_year.to_s) .. Date.parse('28.02.'+next_year.to_s) )
  min_winter_day = winter_range.min
  max_winter_day = winter_range.max
  summer_range = ( Date.parse('01.03.'+current_year.to_s) .. Date.parse('30.09.'+current_year.to_s) )
  min_summer_day = summer_range.min
  max_summer_day = summer_range.max
  # ======================================================================= #
  # Ok, we have all the required dates. Now we have to check on the variable
  # today to find out in which range we are in.
  # ======================================================================= #
  if min_winter_day <= today.to_datetime and max_winter_day >= today.to_datetime
    # e 'Yes, the queried date is part of the date-range.'
    :winter
  else
    # e 'No, the queried date is NOT part of the date-range.'
    if min_summer_day <= today.to_datetime and max_summer_day >= today.to_datetime
      :summer
    else
      :impossible_situation_check_for_flaw_in_the_code
    end
  end
end

#dataset?Boolean

#

dataset?

This query-method won’t be valid for all subclasses, but I consider it useful to have it enabled by default - that way we can avoid having to define it for those subclasses that make use of it.

#

Returns:

  • (Boolean)


3204
3205
3206
# File 'lib/studium/base/base.rb', line 3204

def dataset?
  @internal_hash[:dataset]
end

#datum?Boolean

#

datum?

#

Returns:

  • (Boolean)


2963
2964
2965
# File 'lib/studium/base/base.rb', line 2963

def datum?
  Studium.datum? # ← Available in "studium/toplevel_methods/toplevel_methods.rb".
end

#day_month_year(use_this_time = Time.now) ⇒ Object Also known as: today?, return_day_month_year, dd_mm_yyyy, return_dd_mm_yyyy, time_today

#

day_month_year

This method will return a dd.mm.yyyy notation.

If you need to find out whether the given input-day is today, then use the method called .is_this_day_today?, defined in this file.

An example for this will be:

03.04.2020
#


3062
3063
3064
3065
3066
3067
3068
3069
3070
# File 'lib/studium/base/base.rb', line 3062

def day_month_year(
    use_this_time = Time.now
  )
  if use_this_time.is_a? Time
    use_this_time.strftime('%d.%m.%Y')
  else
    use_this_time
  end
end

#debug?Boolean

#

debug?

#

Returns:

  • (Boolean)


2454
2455
2456
# File 'lib/studium/base/base.rb', line 2454

def debug?
  @internal_hash[:debug]
end

#delete_file(i) ⇒ Object

#

delete_file

#


501
502
503
# File 'lib/studium/base/base.rb', line 501

def delete_file(i)
  File.delete(i) if File.exist? i
end

#directory_of_the_exam_topics?Boolean

#

directory_to_the_exam_topics?

#

directory_of_the_exam_topics?

Returns:

  • (Boolean)


1564
1565
1566
# File 'lib/studium/base/base.rb', line 1564

def directory_to_the_exam_topics?
  Studium.directory_to_the_exam_topics?
end

#directory_to_my_exam_topicsObject

#

directory_to_my_exam_topics

#


1554
1555
1556
# File 'lib/studium/base/base.rb', line 1554

def directory_to_my_exam_topics
  Studium.directory_to_my_exam_topics
end

#directory_to_the_exam_topics?Boolean Also known as: exam_topics_directory?, exam_topic_directory?

#

directory_to_the_exam_topics?

This method will point to the directory where all exam topics are normally kept; it is simply a “wrapper-method”.

#

Returns:

  • (Boolean)


1561
1562
1563
# File 'lib/studium/base/base.rb', line 1561

def directory_to_the_exam_topics?
  Studium.directory_to_the_exam_topics?
end

#disable_coloursObject Also known as: no_colours

#

disable_colours

#


362
363
364
# File 'lib/studium/base/base.rb', line 362

def disable_colours
  @internal_hash[:use_colours] = false
end

#disable_colours_globallyObject

#

disable_colours_globally

Disable the colours globally, that is, on a per-project basis.

#


254
255
256
# File 'lib/studium/base/base.rb', line 254

def disable_colours_globally
  ::Studium.disable_colours # Delegate to the module-method here.
end

#do_not_be_verboseObject Also known as: set_be_quiet

#

do_not_be_verbose

#


462
463
464
# File 'lib/studium/base/base.rb', line 462

def do_not_be_verbose
  @internal_hash[:be_verbose] = false
end

#do_not_use_opnObject

#

do_not_use_opn

#


1436
1437
1438
# File 'lib/studium/base/base.rb', line 1436

def do_not_use_opn
  @internal_hash[:use_opn] = false
end

#do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?(i) ⇒ Boolean

#

do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?(i)

The input to this method should be an Array.

#

Returns:

  • (Boolean)


2575
2576
2577
2578
2579
2580
2581
2582
# File 'lib/studium/base/base.rb', line 2575

def do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?(i)
  result = false
  if i.any? {|entry| entry.start_with?('033')} and
     i.any? {|entry| entry.start_with?('066')}
    result = true
  end
  return result
end

#does_this_line_include_a_german_weekday?(i) ⇒ Boolean Also known as: does_this_string_include_a_german_weekday?

#

does_this_line_include_a_german_weekday?

#

Returns:

  • (Boolean)


2196
2197
2198
2199
2200
# File 'lib/studium/base/base.rb', line 2196

def does_this_line_include_a_german_weekday?(i)
  ARRAY_GERMAN_WEEKDAYS.any? {|this_german_weekday|
    i.include? this_german_weekday
  }
end

#does_this_line_include_a_html_colour?(i) ⇒ Boolean

#

does_this_line_include_a_html_colour?

#

Returns:

  • (Boolean)


2385
2386
2387
# File 'lib/studium/base/base.rb', line 2385

def does_this_line_include_a_html_colour?(i)
  ::Colours.does_this_line_include_a_html_colour?(i)
end

#does_this_line_include_an_english_weekday?(i) ⇒ Boolean

#

does_this_line_include_an_english_weekday?

#

Returns:

  • (Boolean)


2237
2238
2239
2240
2241
# File 'lib/studium/base/base.rb', line 2237

def does_this_line_include_an_english_weekday?(i)
  ARRAY_ENGLISH_WEEKDAYS.any? {|this_english_weekday|
    i.include? this_english_weekday
  }
end

#does_this_line_start_with_a_german_weekday?(i) ⇒ Boolean

#

does_this_line_start_with_a_german_weekday?

#

Returns:

  • (Boolean)


2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
# File 'lib/studium/base/base.rb', line 2842

def does_this_line_start_with_a_german_weekday?(i)
  result = false
  if i.include?(' ')
    i = i.dup
    if i.start_with?(' - "')
      i[0, 4] = ''
    end
    splitted = i.split(' ')
    first    = splitted.first
    if is_german_weekday?(first)
      result = true
    end
  end
  return result
end

#e(i = '') ⇒ Object

#

e (e tag)

#


336
337
338
# File 'lib/studium/base/base.rb', line 336

def e(i = '')
  puts i
end

#ecomment(i = '', use_colours = use_colours? ) ⇒ Object

#

ecomment

#


3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
# File 'lib/studium/base/base.rb', line 3444

def ecomment(
    i           = '',
    use_colours = use_colours?
  )
  if use_colours
    ::Colours.ecomment(i)
  else
    e i
  end
end

#editor?Boolean

#

editor?

#

Returns:

  • (Boolean)


652
653
654
# File 'lib/studium/base/base.rb', line 652

def editor?
  Studium.editor?
end

#ee(i = '') ⇒ Object

#

ee (ee tag)

This is just a wrapper over print, essentially.

#


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

def ee(i = '')
  print i
end

#egrey(i) ⇒ Object

#

egrey

#


1632
1633
1634
# File 'lib/studium/base/base.rb', line 1632

def egrey(i)
  e grey(i)
end

#enable_coloursObject

#

enable_colours

#


355
356
357
# File 'lib/studium/base/base.rb', line 355

def enable_colours
  @internal_hash[:use_colours] = true
end

#enable_colours_globallyObject

#

enable_colours_globally

#


245
246
247
# File 'lib/studium/base/base.rb', line 245

def enable_colours_globally
  ::Studium.enable_colours
end

#enable_debugObject Also known as: do_debug

#

enable_debug

#


754
755
756
# File 'lib/studium/base/base.rb', line 754

def enable_debug
  @internal_hash[:debug] = true
end

#encoding?Boolean Also known as: main_encoding?, main_encoding_to_use?, use_this_encoding?, encoding_to_use?

#

encoding?

This method will return the main encoding in use, by “pointing” towards the constant that keeps track of this.

#

Returns:

  • (Boolean)


662
663
664
# File 'lib/studium/base/base.rb', line 662

def encoding?
  ::Studium.main_encoding?
end

#english_to_german_weekday(english_day) ⇒ Object Also known as: english_to_german

#

english_to_german_weekday

This method will simply convert e. g. “Monday” into “Montag”. In other words: it will convert from the english name for a day into the german name of that day.

#


2250
2251
2252
# File 'lib/studium/base/base.rb', line 2250

def english_to_german_weekday(english_day)
  ENGLISH_TO_GERMAN_WEEKDAYS[english_day]
end

#ensure_that_a_base_directory_exists_for_this_file(i) ⇒ Object

#

ensure_that_a_base_directory_exists_for_this_file

This method expects a file path, such as “/tmp/foo/bar.html”.

If such a file path is passed to this method then this method will try to ensure that /tmp/foo/ exists (the directory).

#


2186
2187
2188
2189
2190
2191
# File 'lib/studium/base/base.rb', line 2186

def ensure_that_a_base_directory_exists_for_this_file(i)
  _ = File.dirname(i)
  unless File.directory?(_)
    FileUtils.mkdir_p(_)
  end
end

#ensure_that_the_log_directory_existsObject

#

ensure_that_the_log_directory_exists

This method will try to make sure that the log directory exists.

#


2673
2674
2675
2676
2677
2678
2679
2680
2681
# File 'lib/studium/base/base.rb', line 2673

def ensure_that_the_log_directory_exists
  _ = log_dir?
  unless File.directory? _
    mkdir(_)
  end
  unless File.directory? "#{_}html/"
    mkdir("#{_}html/")
  end
end

#eparse(i, use_colours = use_colours? ) ⇒ Object Also known as: ecolourize

#

eparse

The colours for this method are defined within the method body.

We could also delegate to ::Colours.eparse() instead.

#


1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
# File 'lib/studium/base/base.rb', line 1666

def eparse(
    i,
    use_colours = use_colours?
  )
  if use_colours
    token = '#'
    if i.include? token
      splitted = i.split(token)
      splitted[-1] = olive(splitted[-1])
      i = splitted.join(royalblue(token))
    end
  end
  e i
end

#esystem(i) ⇒ Object

#

esystem

#


1352
1353
1354
# File 'lib/studium/base/base.rb', line 1352

def esystem(i)
  ::Studium.esystem(i)
end

#etomato(i) ⇒ Object

#

etomato

#


1887
1888
1889
# File 'lib/studium/base/base.rb', line 1887

def etomato(i)
  e tomato(i)
end

#exit_program(make_newline = :no_newline) ⇒ Object

#

exit_program (exit tag)

Use this method to exit from the program. It is a general “exit-operation” for classes in the Studium project. The reason as to why we don’t just simply use exit() is so that we

#


676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/studium/base/base.rb', line 676

def exit_program(
    make_newline = :no_newline
  )
  case make_newline
  # ======================================================================= #
  # === :no_newline
  # ======================================================================= #
  when :no_newline
    make_newline = false
  end
  e(N) if make_newline
  exit # Exit here.
end

#extract_dd_mm_yyyy(i) ⇒ Object Also known as: extract_ddmmyyyy

#

extract_dd_mm_yyyy

This method can be used to extract the dd.mm.yyyy format from the given input at hand. It will discard everything else.

So, for instance, if the input is “15.10.2018, 09:00-18:00” then this method will return only “15.10.2018”.

#


553
554
555
556
# File 'lib/studium/base/base.rb', line 553

def extract_dd_mm_yyyy(i)
  i =~ /(\d{1,2}\.\d{1,2}\.\d{4})/ # This will also generate a match.
  return $1.to_s.dup
end

#fetch_this_curriculum(i, &block) ⇒ Object

#

fetch_this_curriculum

This method can be used to specifically read in a registered local curriculum.

#


1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'lib/studium/base/base.rb', line 1502

def fetch_this_curriculum(i, &block)
  path = map_input_to_this_curriculum_filename(i)
  _ = readlines_with_proper_encoding(path, &block)
  if _
    return _.reject {|line|
      line.strip.empty? or line.strip.start_with?('#')
    }.map {|entry|
      entry.strip!
      entry.squeeze!(' ')
      if entry.include?('#')
        entry = entry.split('#').first.to_s
      end
      entry.strip
    }
  else
    false
  end
end

#file_important_exams?Boolean

#

file_important_exams?

#

Returns:

  • (Boolean)


312
313
314
# File 'lib/studium/base/base.rb', line 312

def file_important_exams?
  return ::Studium.file_important_exams?
end

#file_lecture_information?Boolean

#

file_lecture_information?

#

Returns:

  • (Boolean)


1752
1753
1754
# File 'lib/studium/base/base.rb', line 1752

def file_lecture_information?
  ::Studium.file_lecture_information?
end

#file_passed_exams_per_monthObject Also known as: passed_exams_per_month, local_csv_file?

#

file_passed_exams_per_month

#


1965
1966
1967
# File 'lib/studium/base/base.rb', line 1965

def file_passed_exams_per_month
  Studium.file_passed_exams_per_month
end

#file_read_with_proper_encoding(this_file) ⇒ Object

#

file_read_with_proper_encoding

#


853
854
855
# File 'lib/studium/base/base.rb', line 853

def file_read_with_proper_encoding(this_file)
  Studium.file_read_with_proper_encoding(this_file)
end

#filter_away_already_answered_questions(i) ⇒ Object Also known as: filter_away_already_answered_comments

#

filter_away_already_answered_questions

#


3401
3402
3403
3404
3405
# File 'lib/studium/base/base.rb', line 3401

def filter_away_already_answered_questions(i)
  return i.reject {|entry|
    entry.end_with?(" []\n")
  }
end

#filter_away_invalid_questions(i) ⇒ Object

#

filter_away_invalid_questions

This method will remove entries that begin with ‘#’ and empty entries.

#


3503
3504
3505
# File 'lib/studium/base/base.rb', line 3503

def filter_away_invalid_questions(i)
  Studium.filter_away_invalid_questions(i)
end

#filter_for_all_passed_exams(i) ⇒ Object

#

filter_for_all_passed_exams

#


1877
1878
1879
1880
1881
1882
# File 'lib/studium/base/base.rb', line 1877

def filter_for_all_passed_exams(i)
  return i.select {|a, b|
    b[:already_solved] and
   (b[:already_solved] == true)
  }
end

#find_corresponding_exam_topic(i, be_verbose = be_verbose? ) ⇒ Object Also known as: return_file_associated_with_this_exam_topic, find_corresponding_exam_title, expand_topic, try_to_find_a_registered_exam_topic

#

find_corresponding_exam_topic

This method will try to find the corresponding exam topic, based on a short given input.

For instance, ‘bem1’ will become ‘basic biochemistry’ and ‘amg1’ will become ‘allgemeine_genetik’. If no match is found then the original input will be returned.

#


3369
3370
3371
3372
3373
3374
# File 'lib/studium/base/base.rb', line 3369

def find_corresponding_exam_topic(
    i,
    be_verbose = be_verbose?
  )
  return Studium.find_corresponding_exam_topic(i, be_verbose)
end

#from_curriculum_id_to_university(id) ⇒ Object Also known as: from_curriculum_number_to_university, which_university?

#

from_curriculum_id_to_university

This method will translate from the curriculum-ID to the university. So it will return a String such as “BOKU”.

#


2689
2690
2691
# File 'lib/studium/base/base.rb', line 2689

def from_curriculum_id_to_university(id)
  ::Studium.from_curriculum_id_to_university(id)
end

#german_date_notation(i, use_this_token_as_separator = '-') ⇒ Object Also known as: german_notation, to_german_date, german_formatting_for_the_date

#

german_date_notation

Give a Range as input, and it will give us back a String that shows german date notation, aka DD.MM.YYYY.

#


2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
# File 'lib/studium/base/base.rb', line 2137

def german_date_notation(
    i, use_this_token_as_separator = '-'
  )
  # ======================================================================= #
  # === Handle Range objects next
  # ======================================================================= #
  if i.is_a? Range
    start_date  = i.begin
    end_date    = i.end
    start_day   = start_date.day.to_s.rjust(2, '0')
    start_month = start_date.month.to_s.rjust(2, '0')
    start_year  = start_date.year.to_s
    end_day     = end_date.day.to_s.rjust(2, '0')
    end_month   = end_date.month.to_s.rjust(2, '0')
    end_year    = end_date.year.to_s
    i = start_day+'.'+start_month+'.'+start_year+' '+
        use_this_token_as_separator+' '+
        end_day+'.'+end_month+'.'+end_year
  # ======================================================================= #
  # === Handle Time objects next
  #
  # This requires no token.
  # ======================================================================= #
  elsif i.is_a? Time
    i = "#{i.day.to_s.rjust(2, '0')}."\
        "#{i.month.to_s.rjust(2, '0')}."\
        "#{i.year.to_s}"
  end
  return i
end

#german_weekday?(i = Date.today.wday) ⇒ Boolean Also known as: weekday_at, german_weekday

#

german_weekday?

This method will return a german weekday, for the given input. The input should be the specific wday at hand.

#

Returns:

  • (Boolean)


2464
2465
2466
2467
2468
# File 'lib/studium/base/base.rb', line 2464

def german_weekday?(
    i = Date.today.wday
  )
  weekday?(i, :german)
end

#german_weekdays?Boolean

#

german_weekdays?

#

Returns:

  • (Boolean)


2230
2231
2232
# File 'lib/studium/base/base.rb', line 2230

def german_weekdays?
  ARRAY_GERMAN_WEEKDAYS
end

#german_weekend_for?(i = '22.11.2022') ⇒ Boolean

#

german_weekend_for?

#

Returns:

  • (Boolean)


1954
1955
1956
1957
1958
1959
1960
# File 'lib/studium/base/base.rb', line 1954

def german_weekend_for?(
    i = '22.11.2022'
  )
  if Object.const_defined?(:Roebe)
    return Roebe.return_german_weekday(i)
  end
end

#german_yes_or_no(i) ⇒ Object

#

german_yes_or_no

#


2062
2063
2064
2065
2066
2067
2068
2069
# File 'lib/studium/base/base.rb', line 2062

def german_yes_or_no(i)
  case i
  when true
    'ja'
  when false
    'nein'
  end
end

#has_a_bachelor_and_a_master_curriculum?(i) ⇒ Boolean

#

has_a_bachelor_and_a_master_curriculum?

#

Returns:

  • (Boolean)


2731
2732
2733
# File 'lib/studium/base/base.rb', line 2731

def has_a_bachelor_and_a_master_curriculum?(i)
  has_a_bachelor_curriculum?(i) and has_a_master_curriculum?(i)
end

#has_a_bachelor_curriculum?(array) ⇒ Boolean Also known as: has_a_bachelor_curriculum_entry?, is_a_bachelor_lecture?, is_a_bachelor_curriculum?, does_this_include_a_bachelor_curriculum?

#

has_a_bachelor_curriculum?

This method will return true if the given Array has any bachelor curriculum; and it will return false otherwise.

#

Returns:

  • (Boolean)


2813
2814
2815
# File 'lib/studium/base/base.rb', line 2813

def has_a_bachelor_curriculum?(array)
  Studium.has_a_bachelor_curriculum?(array)
end

#has_a_master_curriculum?(array) ⇒ Boolean Also known as: is_a_master_curriculum?, has_a_master_lecture?, has_a_master_curriculum_entry?, is_this_lecture_registered_in_a_master_curriculum?, does_this_include_a_master_curriculum?

#

has_a_master_curriculum?

This method will return true if the given Array has any master curriculum; and it will return false otherwise.

Note that there is an alias called “is_this_lecture_registered_in_a_master_curriculum?”. The name is a of a misnomer, since the input to this method should be an Array containing the IDs of the Curricula for which that lecture is registered. This may be subject for change one day, but for now (Sep 2018) we will keep it that way.

#

Returns:

  • (Boolean)


1460
1461
1462
# File 'lib/studium/base/base.rb', line 1460

def has_a_master_curriculum?(array)
  Studium.has_a_master_curriculum?(array)
end

#has_lva_dates_registered?(i) ⇒ Boolean Also known as: has_any_lva_dates_registered?

#

has_lva_dates_registered?

#

Returns:

  • (Boolean)


1813
1814
1815
1816
1817
1818
1819
1820
# File 'lib/studium/base/base.rb', line 1813

def has_lva_dates_registered?(i)
  return false if i.nil? or i.empty? # Reject impossible values quickly.
  if i.is_a?(Array) and !i.empty?
    true
  else
    false
  end
end

#has_this_exam_topic_been_solved?(i) ⇒ Boolean

#

has_this_exam_topic_been_solved?

#

Returns:

  • (Boolean)


483
484
485
# File 'lib/studium/base/base.rb', line 483

def has_this_exam_topic_been_solved?(i)
  (Studium.return_n_percent_solved_from_this_topic(i).to_i == 100)
end

#has_year_entry?(this_line) ⇒ Boolean Also known as: this_line_has_a_year_entry?

#

has_year_entry?

This method will return a Boolean.

It will return true if the line has a year entry such as ‘2018’; and it will return false, otherwise.

#

Returns:

  • (Boolean)


2566
2567
2568
# File 'lib/studium/base/base.rb', line 2566

def has_year_entry?(this_line)
  this_line =~ /\d{4}/ # If this line has at the least one entry with 4 numbers.
end

#hh_mm_ss_dd_mm_yyyy(i) ⇒ Object

#

hh_mm_ss_dd_mm_yyyy

#


2406
2407
2408
# File 'lib/studium/base/base.rb', line 2406

def hh_mm_ss_dd_mm_yyyy(i)
  "#{hh_mm_ss(i)}-#{dd_mm_yyyy(i)}"
end

#horizontal_bar?Boolean

#

horizontal_bar?

#

Returns:

  • (Boolean)


1691
1692
1693
# File 'lib/studium/base/base.rb', line 1691

def horizontal_bar?
  return ''
end

#html_log_directory?Boolean Also known as: html_log_dir?

#

html_log_dir?

#

Returns:

  • (Boolean)


434
435
436
# File 'lib/studium/base/base.rb', line 434

def html_log_directory?
  Studium.html_log_directory?
end

#infer_the_namespaceObject

#

infer_the_namespace

This will assume the true namespace from the inspectable name.

#


1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
# File 'lib/studium/base/base.rb', line 1761

def infer_the_namespace
  _ = inspect.to_s.delete('<')
  if _.include? ' '
    _ = _.split(' ').first.delete('#')
    if _.include? ':'
      _ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
    end
  end
  @internal_hash[:namespace] = _ # And assign it here.
end

#initialize_the_internal_hashObject Also known as: reset_the_internal_hash

#

initialize_the_internal_hash

#


199
200
201
202
203
204
# File 'lib/studium/base/base.rb', line 199

def initialize_the_internal_hash
  # ======================================================================= #
  # === @internal_hash
  # ======================================================================= #
  @internal_hash = {}
end

#internal_hash?Boolean Also known as: ihash?

#

internal_hash?

#

Returns:

  • (Boolean)


261
262
263
# File 'lib/studium/base/base.rb', line 261

def internal_hash?
  @internal_hash
end

#is_a_master_lecture?(i) ⇒ Boolean

#

is_a_master_lecture?

#

Returns:

  • (Boolean)


1894
1895
1896
# File 'lib/studium/base/base.rb', line 1894

def is_a_master_lecture?(i)
  Studium.is_a_master_lecture?(i)
end

#is_a_registered_curriculum?(i) ⇒ Boolean

#

is_a_registered_curriculum?

This calls code stored in the file /require ‘studium/toplevel_methods/toplevel_methods.rb’.

#

Returns:

  • (Boolean)


427
428
429
# File 'lib/studium/base/base.rb', line 427

def is_a_registered_curriculum?(i)
  return Studium.is_a_registered_curriculum?(i)
end

#is_a_weekday?(i = 'Montag') ⇒ Boolean

#

is_a_weekday?

This method will return true if the input is a String that represents a weekday, such as “Monday”. Otherwise, false will be returned.

Both german and english variants are allowed here.

#

Returns:

  • (Boolean)


2217
2218
2219
2220
2221
2222
2223
2224
2225
# File 'lib/studium/base/base.rb', line 2217

def is_a_weekday?(i = 'Montag')
  result = false
  if ARRAY_GERMAN_WEEKDAYS.include? i
    result = true
  elsif ARRAY_ENGLISH_WEEKDAYS.include? i
    result = true
  end
  return result
end

#is_connected_to_the_www?Boolean

#

is_connected_to_the_www?

#

Returns:

  • (Boolean)


395
396
397
# File 'lib/studium/base/base.rb', line 395

def is_connected_to_the_www?
  !@internal_hash[:no_connection_to_the_www]
end

#is_german_weekday?(i) ⇒ Boolean

#

is_german_weekday?

#

Returns:

  • (Boolean)


2205
2206
2207
# File 'lib/studium/base/base.rb', line 2205

def is_german_weekday?(i)
  ARRAY_GERMAN_WEEKDAYS.include?(i)
end

#is_on_roebe?Boolean Also known as: is_roebe?, on_roebe?

#

is_on_roebe?

#

Returns:

  • (Boolean)


588
589
590
# File 'lib/studium/base/base.rb', line 588

def is_on_roebe?
  Studium.is_on_roebe?
end

#is_prüfungsimmanent?(i, ignore_these_types = nil) ⇒ Boolean Also known as: is_a_prüfungsimmanent_course?, is_this_a_prüfungsimment_course?, is_this_a_prüfungsimmanent_course?

#

is_prüfungsimmanent?

This method can determine whether a course is “prüfungsimmanent”, aka whether this course requires continuous, mandatory presence (of the student).

The argument to this method should be the type of the lecture at hand, such as “VO” or “VU” or “SE” or “PR”, as a String.

The method will always return a boolean value, aka true or false. If true is the return value then this means that “yes, this course requires mandatory presence”.

#

Returns:

  • (Boolean)


1793
1794
1795
1796
1797
# File 'lib/studium/base/base.rb', line 1793

def is_prüfungsimmanent?(
    i, ignore_these_types = nil
  )
  Studium.is_prüfungsimmanent?(i, ignore_these_types)
end

#is_this_a_registered_exam_topic?(i) ⇒ Boolean

#

is_this_a_registered_exam_topic?

This method must return a boolean - true if the given input is a registere exam topic; and false otherwise.

#

Returns:

  • (Boolean)


3385
3386
3387
3388
3389
# File 'lib/studium/base/base.rb', line 3385

def is_this_a_registered_exam_topic?(i)
  original_input = i.dup
  possibly_expanded_input = try_to_find_a_registered_exam_topic(original_input)
  return original_input == possibly_expanded_input
end

#is_this_a_valid_html_colour?(i) ⇒ Boolean Also known as: is_this_colour_a_html_colour?

#

is_this_a_valid_html_colour?

This method will let us know whether the given input is a valid (aka registered) “html colour”. An example for this would be the String ‘slateblue’.

#

Returns:

  • (Boolean)


2506
2507
2508
# File 'lib/studium/base/base.rb', line 2506

def is_this_a_valid_html_colour?(i)
  ::Studium.is_this_a_valid_html_colour?(i)
end

#is_this_day_today?(i = '18.02.2022') ⇒ Boolean

#

is_this_day_today?

This method will return true or false, depending on whether the given input is assumed to be the present day or not.

The method assumes that the input will be a Time object normally.

#

Returns:

  • (Boolean)


3100
3101
3102
3103
3104
# File 'lib/studium/base/base.rb', line 3100

def is_this_day_today?(
    i = '18.02.2022'
  )
  dd_mm_yyyy(Time.now) == dd_mm_yyyy(i)
end

#is_this_lecture_a_practical_course?(this_lecture, optional_lecture_type = nil) ⇒ Boolean Also known as: is_this_lecture_a_practical_course, is_it_a_practical_course?

#

is_this_lecture_a_practical_course?

#

Returns:

  • (Boolean)


1837
1838
1839
1840
1841
1842
# File 'lib/studium/base/base.rb', line 1837

def is_this_lecture_a_practical_course?(
    this_lecture,
    optional_lecture_type = nil
  )
  ::Studium.is_this_lecture_a_practical_course?(this_lecture, optional_lecture_type)
end

#konsole_support?Boolean

#

konsole_support?

#

Returns:

  • (Boolean)


955
956
957
# File 'lib/studium/base/base.rb', line 955

def konsole_support?
  true
end

#last_file?Boolean

#

last_file?

#

Returns:

  • (Boolean)


974
975
976
977
978
979
980
981
982
983
984
# File 'lib/studium/base/base.rb', line 974

def last_file?
  _ = Studium.file_for_exam_questions
  _ = load_yaml_dataset(_).chomp
  # ======================================================================= #
  # If we are on roebe then we will use another path.
  # ======================================================================= #
  if is_on_roebe?
    _ = Studium::MY_EXAM_TOPICS+File.basename(_)
  end
  return _
end

#lectures_from_indi1Object

#

lectures_from_indi1

#


768
769
770
# File 'lib/studium/base/base.rb', line 768

def lectures_from_indi1
  obtain_lectures_from_this_curriculum(:indi1)
end

#lectures_from_indi2Object

#

lectures_from_indi2

#


775
776
777
# File 'lib/studium/base/base.rb', line 775

def lectures_from_indi2
  obtain_lectures_from_this_curriculum(:indi2)
end

#lectures_from_indi3Object

#

lectures_from_indi3

#


782
783
784
# File 'lib/studium/base/base.rb', line 782

def lectures_from_indi3
  obtain_lectures_from_this_curriculum(:indi3)
end

#lectures_from_indi4Object

#

lectures_from_indi4

#


789
790
791
# File 'lib/studium/base/base.rb', line 789

def lectures_from_indi4
  obtain_lectures_from_this_curriculum(:indi4)
end

#lectures_from_the_bachelor_genetik_curriculumObject

#

lectures_from_the_bachelor_genetik_curriculum

#


803
804
805
# File 'lib/studium/base/base.rb', line 803

def lectures_from_the_bachelor_genetik_curriculum
  obtain_lectures_from_this_curriculum(:bachelor_genetik_curriculum)
end

#lectures_from_the_individual_vektor_curriculaObject

#

lectures_from_the_individual_vektor_curricula

This method is a convenience method, returning all the lectures that belong to the individual bachelor+master vektor-curriculum

#


3413
3414
3415
3416
3417
3418
# File 'lib/studium/base/base.rb', line 3413

def lectures_from_the_individual_vektor_curricula
  (
    obtain_lectures_from_this_curriculum(:bachelor_vektor)+
    obtain_lectures_from_this_curriculum(:master_vektor)
  ).flatten
end

#left_arrow?Boolean Also known as: left_arrow

#

left_arrow

#

Returns:

  • (Boolean)


1775
1776
1777
# File 'lib/studium/base/base.rb', line 1775

def left_arrow?
  ''
end

#load_yaml_dataset(i, do_rescue = false) ⇒ Object

#

load_yaml_dataset

This method should ideally be used whenever a .yml file is to be loaded.

The second argument can be used to rescue missing or erroneous yaml files.

Invocation example for this is:

load_yaml_dataset(:rescue)
#


731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
# File 'lib/studium/base/base.rb', line 731

def load_yaml_dataset(
    i,
    do_rescue = false
  )
  case do_rescue
  # ======================================================================= #
  # === :rescue
  # ======================================================================= #
  when :rescue
    do_rescue = true
  end
  if do_rescue
    begin
      YAML.load_file(i)
    rescue LoadError, ArgumentError; end
  else
    YAML.load_file(i)
  end
end

#map_input_to_this_curriculum_filename(i) ⇒ Object

#

map_input_to_this_curriculum_filename

#


2823
2824
2825
# File 'lib/studium/base/base.rb', line 2823

def map_input_to_this_curriculum_filename(i)
  ::Studium.map_input_to_this_curriculum_filename(i)
end

#move_file(this_file, target) ⇒ Object

#

move_file

#


476
477
478
# File 'lib/studium/base/base.rb', line 476

def move_file(this_file, target)
  FileUtils.mv(this_file, target)
end

#n_days_difference_from_today_to_this_day(time_now = Time.now, name_of_the_future_day) ⇒ Object

#

n_days_difference_from_today_to_this_day

This method will return a number, which is the amount of days between weekdays.

The days are numbered like this:

Monday:    1
Tuesday:   2
Wednesday: 3
Thursday:  4
Friday:    5
Saturday:  6
Sunday:    0

So, how to calculate the time difference to the next day?

Well, say we have the current day be a Wednesday, and the day that is to be compared, a Friday. The difference is thus (5 - 3 = 2). If the current day is a Saturday, and the input-day is a Friday, then the difference must be 5.

If we have, for example, “Friday” to “Tuesday”, then this method should return the number 4, because the distance is that: Friday, Saturday, Sunday and Monday (the start day has to be included, as lectures can happen on that day still, e. g. if you check early in the morning, you could still have courses in the evening slots scheduled).

#


2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
# File 'lib/studium/base/base.rb', line 2284

def n_days_difference_from_today_to_this_day(
    time_now = Time.now,
    name_of_the_future_day # ← This ought to be a String, such as "Monday".
  )
  n_days_difference = 0
  weekday_as_number = time_now.wday
  name_of_the_future_day = name_of_the_future_day.dup if name_of_the_future_day.frozen?
  name_of_the_future_day.strip! # We better strip that input.
  start_day = Date::DAYNAMES[weekday_as_number]
  # ======================================================================= #
  # The next is simply a hardcoded table. We will begin with the
  # future day.
  # ======================================================================= #
  n_days_difference =
  case start_day
  when 'Monday'
    case name_of_the_future_day
    when 'Tuesday'   then 1
    when 'Wednesday' then 2
    when 'Thursday'  then 3
    when 'Friday'    then 4
    when 'Saturday'  then 5
    when 'Sunday'    then 6
    end
  when 'Tuesday'
    case name_of_the_future_day
    when 'Wednesday' then 1
    when 'Thursday'  then 2
    when 'Friday'    then 3
    when 'Saturday'  then 4
    when 'Sunday'    then 5
    when 'Monday'    then 6
    end
  when 'Wednesday'
    case name_of_the_future_day
    when 'Thursday'  then 1
    when 'Friday'    then 2
    when 'Saturday'  then 3
    when 'Sunday'    then 4
    when 'Monday'    then 5
    when 'Tuesday'   then 6
    end
  when 'Thursday'
    case name_of_the_future_day
    when 'Friday'    then 1
    when 'Saturday'  then 2
    when 'Sunday'    then 3
    when 'Monday'    then 4
    when 'Tuesday'   then 5
    when 'Wednesday' then 6
    end
  when 'Friday'
    case name_of_the_future_day
    when 'Saturday'  then 1
    when 'Sunday'    then 2
    when 'Monday'    then 3
    when 'Tuesday'   then 4
    when 'Wednesday' then 5
    when 'Thursday'  then 6
    end
  when 'Saturday'
    case name_of_the_future_day
    when 'Sunday'    then 1
    when 'Monday'    then 2
    when 'Tuesday'   then 3
    when 'Wednesday' then 4
    when 'Thursday'  then 5
    when 'Friday'    then 6
    end
  when 'Sunday'
    case name_of_the_future_day
    when 'Monday'    then 1
    when 'Tuesday'   then 2
    when 'Wednesday' then 3
    when 'Thursday'  then 4
    when 'Friday'    then 5
    when 'Saturday'  then 6
    end
  end
  return n_days_difference
end

#n_seconds_to_n_days(i) ⇒ Object

#

n_seconds_to_n_days

A day has 60 seconds * 60 minutes

#


3280
3281
3282
3283
3284
# File 'lib/studium/base/base.rb', line 3280

def n_seconds_to_n_days(i)
  hour = 60 * 60.0
  one_day = hour * 24
  return (i / one_day.to_f)
end

#namespace?Boolean

#

namespace?

#

Returns:

  • (Boolean)


329
330
331
# File 'lib/studium/base/base.rb', line 329

def namespace?
  @internal_hash[:namespace]
end

#no_ext_name(i) ⇒ Object

#

no_ext_name

This method will return the name of the file (or rather the input given to this method) without extension.

#


713
714
715
# File 'lib/studium/base/base.rb', line 713

def no_ext_name(i)
  i.sub(/#{File.extname(i)}$/,'')
end

#no_file_exists_at(i) ⇒ Object Also known as: no_file_at

#

no_file_exists_at

#


268
269
270
# File 'lib/studium/base/base.rb', line 268

def no_file_exists_at(i)
  e "#{rev}No file exists at #{sfile(i)}."
end

#number_to_month(i) ⇒ Object

#

number_to_month

This method will convert a number, such as 6, to the corresponding month entry.

#


2932
2933
2934
2935
2936
# File 'lib/studium/base/base.rb', line 2932

def number_to_month(i)
  array = Date::MONTHNAMES
  i = i.to_i
  return array[i]
end

#obtain(this_key, hash, be_verbose = true) ⇒ Object Also known as: obtain_this_value_from_hash, obtain_from

#

obtain (obtain tag)

This method will attempt to return the entry point of our main hash.

It is optimized towards the dataset stored in the file ‘lecture_information.yml’.

Typical usage example:

curricula = obtain(:curricula, pointer_to_the_lecture_dataset)
#


1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
# File 'lib/studium/base/base.rb', line 1029

def obtain(
    this_key, hash, be_verbose = true
  )
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :be_quiet
    # ===================================================================== #
    when :be_quiet
      be_verbose = false
    end
  end
  case be_verbose
  when :be_quiet,
       :be_silent
    be_verbose = false
  end
  # ======================================================================= #
  # The following case menu will make use of some common popular aliases
  # or typos.
  # ======================================================================= #
  case this_key
  # ======================================================================= #
  # === :passed_when
  # ======================================================================= #
  when :passed_when,
       :solved_at
    this_key = :already_solved_at
  # ======================================================================= #
  # === :passed_successfully
  # ======================================================================= #
  when :passed_successfully
    this_key = :already_solved
  # ======================================================================= #
  # === :steop
  # ======================================================================= #
  when :steop,
       'steop'
    this_key = :is_a_steop_lecture
  # ======================================================================= #
  # === :curricula_entries
  # ======================================================================= #
  when :curricula_entries,
       :curricula,
       'curricula'
    this_key = 'curricula'
  # ======================================================================= #
  # === :english_description
  # ======================================================================= #
  when :english_description
    this_key = :description_in_english
  # ======================================================================= #
  # === :german_description
  # ======================================================================= #
  when :german_description
    this_key = :description_in_german
  # ======================================================================= #
  # === :this_university
  # ======================================================================= #
  when :this_university,
       :university
    this_key = :university
  # ======================================================================= #
  # === :n_ects
  # ======================================================================= #
  when :n_ects, :n_ects_points
    this_key = :ects
  # ======================================================================= #
  # === :curricula_ids
  # ======================================================================= #
  when :curricula_ids,
       :curriculum_id
    this_key = 'curricula'
  # ======================================================================= #
  # === :lecturers
  # ======================================================================= #
  when :lecturers
    this_key = 'lecturers'
  # ======================================================================= #
  # === :semester
  # ======================================================================= #
  when 'homepage',
       :remote_url
    this_key = :homepage
  # ======================================================================= #
  # === :semester
  # ======================================================================= #
  when :semester, 'semester'
    this_key = :semester
  end
  # ======================================================================= #
  # Work on any other symbols given to us next.
  # ======================================================================= #
  if this_key.is_a? Symbol
    if hash.has_key? this_key
      # All is fine.
    elsif hash.has_key? this_key.to_s
      # Else use that String as key instead.
      this_key = this_key.to_s
    end
  end
  if hash.is_a? Symbol
    e "Symbol called :#{slateblue(hash.to_s)}"
    e swarn('This is not allowed - please correct this. '\
      '(Read the next line in how to do so.)')
    e swarn('This method requires (1) first the key, (2) then the Hash.')
    exit
  elsif hash.is_a?(Hash) and hash.has_key?(this_key)
    hash[this_key] # Return this.
  else
    if be_verbose
      case this_key
      when :is_a_steop_lecture
        # Exceptions - these keys ^^^ will NOT be shown.
      else
        e "In file #{sfile('base.rb')}, method: obtain() → No key found, "\
          "called `#{this_key.to_s}` (class '#{this_key.class.to_s})"
        e 'The hash was:'
        e
        pp hash
        e
      end
    end
    nil
  end
end

#obtain_lectures_from_this_curriculum(i = :default, do_flatten_the_result = true) ⇒ Object Also known as: return_lectures_from_this_curriculum, return_lectures_of_this_curriculum, return_lectures_from_this_curriculu, return_lectures_from_this_curriculum_file, obtain_all_lectures_from_this_curriculum

#

obtain_lectures_from_this_curriculum

This method should be used whenever you wish to obtain all lectures that belong to a specific curriculum, without any comments.

An Array will be returned by this method.

#


3428
3429
3430
3431
3432
3433
3434
3435
# File 'lib/studium/base/base.rb', line 3428

def obtain_lectures_from_this_curriculum(
    i                     = :default,
    do_flatten_the_result = true
  )
  Studium.read_dataset_from_a_curriculum_file(i, :remove_comments, do_flatten_the_result).map {|entry|
    entry.squeeze(' ') # ← We don't want multiple ' ' in succession here.
  }
end

#open_in_browser(i) ⇒ Object

#

open_in_browser

#


3158
3159
3160
3161
# File 'lib/studium/base/base.rb', line 3158

def open_in_browser(i)
  try_to_require_the_open_gem unless Object.const_defined?(:Open)
  Open.in_browser(i)
end

#open_in_editor(i) ⇒ Object

#

open_in_editor

#


645
646
647
# File 'lib/studium/base/base.rb', line 645

def open_in_editor(i)
  Studium.open_in_editor(i)
end

#opne(i) ⇒ Object

#

opne

#


441
442
443
# File 'lib/studium/base/base.rb', line 441

def opne(i)
  opnn; e i
end

#opnerev(i) ⇒ Object

#

opnerev

#


448
449
450
# File 'lib/studium/base/base.rb', line 448

def opnerev(i)
  opne "#{rev}#{i}"
end

#opnn(i = namespace?, , &block) ⇒ Object

#

opnn

The method also handles blocks.

#


2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
# File 'lib/studium/base/base.rb', line 2487

def opnn(
    i = namespace?,
    &block
  )
  if use_opn?
    if i.is_a? String # "Turn" it into a Hash here.
      i = { namespace: i }
    end
    Opn.opn(i, &block)
  end
end

#padded_current_month?(i = current_month? ) ⇒ Boolean

#

padded_current_month?

#

Returns:

  • (Boolean)


319
320
321
322
323
324
# File 'lib/studium/base/base.rb', line 319

def padded_current_month?(
    i = current_month?
  )
  _ = i.to_s
  return ('%02d' % _)
end

#parse_dd_mm_yyyy(i = '03.05.2023') ⇒ Object

#

parse_dd_mm_yyyy

#


3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
# File 'lib/studium/base/base.rb', line 3079

def parse_dd_mm_yyyy(
    i = '03.05.2023'
  )
  if i.is_a? String
    if i.include? ' '
      i = i.split(' ').last.to_s.strip
    end
    return ::Time.parse(i)
  else
    return i
  end
end

#parse_this_line_for_date_entry(i) ⇒ Object

#

parse_this_line_for_date_entry

#


1944
1945
1946
1947
1948
1949
# File 'lib/studium/base/base.rb', line 1944

def parse_this_line_for_date_entry(i)
  use_this_regex = /\d{2}\.\d{2}\.\d{4}/ # See: https://rubular.com/r/ePRbty9Cjo49xv
  result = i.scan(use_this_regex).flatten
  result = result.first if result.is_a? Array
  return result
end

#path_to_exam_topic?Boolean

#

directory_to_the_exam_topics?

#

path_to_exam_topic?

Returns:

  • (Boolean)


1563
1564
1565
# File 'lib/studium/base/base.rb', line 1563

def directory_to_the_exam_topics?
  Studium.directory_to_the_exam_topics?
end

#project_yaml_directory?Boolean

#

project_yaml_directory?

#

Returns:

  • (Boolean)


3394
3395
3396
# File 'lib/studium/base/base.rb', line 3394

def project_yaml_directory?
  Studium.project_yaml_directory?
end

#rds(i) ⇒ Object

#

rds

#


2648
2649
2650
# File 'lib/studium/base/base.rb', line 2648

def rds(i)
  i.squeeze('/')
end

#read_dataset_from_a_curriculum_file(i, optional_commands = :remove_comments) ⇒ Object

#

read_dataset_from_a_curriculum_file

#


2800
2801
2802
2803
2804
2805
# File 'lib/studium/base/base.rb', line 2800

def read_dataset_from_a_curriculum_file(
    i,
    optional_commands = :remove_comments
  )
  Studium.read_dataset_from_a_curriculum_file(i, optional_commands)
end

#read_in_exam_dataset_from_this_file(this_file, shall_we_filter_away_invalid_questions = true, &block) ⇒ Object Also known as: obtain_exam_questions_from_this_file

#

read_in_exam_dataset_from_this_file

This is the method that will read from an existing file. If a symbol is given then we will expand this to the default exam-topic directory.

#


3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
# File 'lib/studium/base/base.rb', line 3461

def read_in_exam_dataset_from_this_file(
    this_file,
    shall_we_filter_away_invalid_questions = true,
    &block
  )
  if this_file.is_a? Symbol
    this_file = "#{exam_topic_directory?}#{this_file}"
  end
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if File.exist? this_file
    dataset = readlines_via_default_encoding(this_file) # First read in the dataset.
    if block_given?
      yielded = yield
      case yielded
      # =================================================================== #
      # === :filter_away_the_comments
      # =================================================================== #
      when :filter_away_the_comments
        shall_we_filter_away_invalid_questions = true
      # =================================================================== #
      # === :filter_away_already_answered_comments
      # =================================================================== #
      when :filter_away_already_answered_comments
         dataset.reject! {|entry|
           entry.rstrip.end_with?(' []')
         }
      end
    end
    if shall_we_filter_away_invalid_questions
      dataset = filter_away_invalid_questions(dataset)
    end
    return dataset
  end
end

#read_this_file_with_default_encoding(this_file) ⇒ Object Also known as: read_as_string_with_default_encoding, read_file, read_this_file, read_file_with_default_encoding, read_in_with_default_encoding

#

read_this_file_with_default_encoding

This method will read in a file, that should ideally exist, in the default project-wide encoding.

A few aliases exist to this method, such as “read_this_file()”.

#


2121
2122
2123
2124
2125
# File 'lib/studium/base/base.rb', line 2121

def read_this_file_with_default_encoding(
    this_file
  )
  File.read(this_file, encoding: ::Studium.main_encoding?)
end

#readlines_from_this_input_file(this_file, use_this_encoding = :default_encoding, &block) ⇒ Object Also known as: readlines_via_default_encoding, readlines_with_default_encoding, readlines_with_the_default_encoding, file_readlines_of_this_file, file_readlines, readlines_with_proper_encoding, proper_readlines, default_readlines, readlines

#

readlines_from_this_input_file

This method is essentially File.readlines(), but we also use the :encoding symbol to denote which Encoding to use.

As first argument pass in the file path to the target input file.

You should ideally use this method in a unified way, that is, whenever you want to read the content of a file make use of this method here. This makes it easier to have the functionality all in one place.

Keep in mind that the file in question has to exist locally; the file here will NOT check whether the given input file exists.

#


3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
# File 'lib/studium/base/base.rb', line 3301

def readlines_from_this_input_file(
    this_file,
    use_this_encoding = :default_encoding,
    &block
  )
  yielded = nil
  if block_given?
    yielded = yield
  end
  case use_this_encoding
  # ======================================================================= #
  # === :default
  #
  # This refers to the default encoding, which is usually UTF-8 (Unicode).
  # ======================================================================= #
  when :default,
       :default_encoding
    use_this_encoding = ::Studium.main_encoding?
  end
  if use_this_encoding.is_a? Hash
    # ===================================================================== #
    # === :encoding
    # ===================================================================== #
    if use_this_encoding.has_key? :encoding
      use_this_encoding = use_this_encoding[:encoding]
    end
  end
  if this_file
    if this_file.is_a? Array
      return this_file.map {|inner_entry|
        if File.exist?(inner_entry)
          inner_entry = File.readlines(inner_entry, encoding: use_this_encoding)
        end
        inner_entry
      }.flatten
    elsif File.exist?(this_file)
      return File.readlines(
        this_file,
        encoding: use_this_encoding
      )
    end
  else
    unless yielded == :be_quiet
      e "Can not read in the file at #{this_file} as it does not exist."
    end
    return false
  end
end

#register_sigintObject

#

register_sigint

#


209
210
211
# File 'lib/studium/base/base.rb', line 209

def register_sigint
  Signal.trap('SIGINT') { exit }
end

#remove_empty_strings(i) ⇒ Object

#

remove_empty_strings

This method presently only works on Arrays. We will reject empty Strings from the Array at hand.

#


1222
1223
1224
1225
1226
# File 'lib/studium/base/base.rb', line 1222

def remove_empty_strings(i)
  if i.is_a? Array
    i.reject {|line| line.empty? }
  end
end

#remove_escape_sequences(i) ⇒ Object

#

remove_escape_sequences

#


1650
1651
1652
1653
1654
1655
1656
1657
# File 'lib/studium/base/base.rb', line 1650

def remove_escape_sequences(i)
  if Object.const_defined?(:Colours) and
    ::Colours.respond_to?(:remove_escape_sequences)
    ::Colours.remove_escape_sequences(i)
  else
    i
  end
end

#remove_internal_comments(i) ⇒ Object

#

remove_internal_comments

#


508
509
510
511
512
513
514
515
516
517
# File 'lib/studium/base/base.rb', line 508

def remove_internal_comments(i)
  if i.is_a? Array
    i.map {|line|
      if line.include? '#'
        line = line[0 .. (line.index('#') - 1)]
      end
      line.strip
    }
  end
end

#remove_leading_comments(i) ⇒ Object

#

remove_leading_comments

#


1210
1211
1212
1213
1214
# File 'lib/studium/base/base.rb', line 1210

def remove_leading_comments(i)
  if i.is_a? Array
    i.reject {|line| line.start_with? '#' }
  end
end

#remove_leading_weekday_names_from(i) ⇒ Object Also known as: remove_german_weekdays, remove_german_weekdays_from, remove_leading_weeknames, remove_leading_weekdays, remove_workday_from_this_input, remove_german_days

#

remove_leading_weekday_names_from

Chop away the leading weekday, e. g. “Monday”, from the String at hand.

#


576
577
578
# File 'lib/studium/base/base.rb', line 576

def remove_leading_weekday_names_from(i)
  Studium.remove_leading_weekday_names_from(i)
end

#remove_newlines(i) ⇒ Object

#

remove_newlines

This method will remove newlines, aka “n”, from Strings and Arrays.

#


1341
1342
1343
1344
1345
1346
1347
# File 'lib/studium/base/base.rb', line 1341

def remove_newlines(i)
  if i.is_a? Array
    i.map {|entry| remove_newlines(entry) }
  else
    i.delete(N)
  end
end

#remove_tags_from_this_input(i) ⇒ Object Also known as: remove_tags

#

remove_tags_from_this_input

This method will return all HTML-like tags from the given input String.

#


1422
1423
1424
# File 'lib/studium/base/base.rb', line 1422

def remove_tags_from_this_input(i)
  return Studium.remove_tags(i)
end

#rename_kde_konsole_tab(title = '.') ⇒ Object

#

rename_kde_konsole_tab

#


962
963
964
965
966
967
968
969
# File 'lib/studium/base/base.rb', line 962

def rename_kde_konsole_tab(
    title = '.'
  )
  if Object.const_defined?(:Roebe) and
     Roebe.respond_to?(:rename_konsole_title_to)
    Roebe.rename_konsole_title_to(title, :be_quiet)
  end
end

#rename_konsole_tab?(i = FILE_RENAME_KONSOLE_TAB) ⇒ Boolean

#

rename_konsole_tab?

#

Returns:

  • (Boolean)


1569
1570
1571
1572
1573
1574
1575
1576
1577
# File 'lib/studium/base/base.rb', line 1569

def rename_konsole_tab?(
    i = FILE_RENAME_KONSOLE_TAB
  )
  if File.exist? i
    YAML.load_file(i)
  else
    false
  end
end

#replace_all_html_colours_in_this(i, use_this_colour_for_the_default_colour = colour_for_questions? ) ⇒ Object

#

replace_all_html_colours_in_this

This method will replace all HTML colours, such as <slateblue>, with the corresponding RGB colour variant for the commandline. Typically this refers to a terminal such as the KDE konsole, and a shell such as bash (although other shells are fine too, and many other terminals, such as the gnome-terminal, most likely will work fine as well - but it is optimized for the KDE konsole).

This method should only be called after a prior check was done, to determine whether the given input String at hand does indeed include a valid HTML colour. This can be done via a call to the method called line_contains_a_valid_html_colour?().

#


2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
# File 'lib/studium/base/base.rb', line 2425

def replace_all_html_colours_in_this(
    i,
    use_this_colour_for_the_default_colour = colour_for_questions?
  )
  # ======================================================================= #
  # bl $RUBY_COLOURS/toplevel_methods/replace_all_html_colours_in_this_line.rb
  # ======================================================================= #
  ::Colours.replace_all_html_colours_in_this_line(
    i, use_this_colour_for_the_default_colour
  )
end

#replace_bold_token_with_default_colour(i, use_this_colour = :mediumseagreen) ⇒ Object

#

replace_bold_token_with_default_colour

This method can be used to replace with the corresponding colour code on the terminal.

#


405
406
407
408
409
410
411
412
# File 'lib/studium/base/base.rb', line 405

def replace_bold_token_with_default_colour(
    i, use_this_colour = :mediumseagreen
  )
  i.gsub(
    /<b>(.+)<\/b>/,
    ::Colours.bold('\1')
  )
end

#replace_italic_token_with_default_colour(i, colour_to_use = :royalblue) ⇒ Object

#

replace_italic_token_with_default_colour

#


1582
1583
1584
# File 'lib/studium/base/base.rb', line 1582

def replace_italic_token_with_default_colour(i, colour_to_use = :royalblue)
  replace_italic_token_with_this_colour(i, colour_to_use)
end

#replace_italic_token_with_this_colour(i, use_this_colour = :mediumseagreen) ⇒ Object

#

replace_italic_token_with_this_colour

This method can be used to replace with the corresponding colour code on the terminal.

#


1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
# File 'lib/studium/base/base.rb', line 1378

def replace_italic_token_with_this_colour(
    i, use_this_colour = :mediumseagreen
  )
  use_this_regex = /<it?>([A-Za-zöäüÖÄÜ\s]+)<\/it?>/ # See: https://rubular.com/r/mZb1ZtGHCLhg2U
  if ::Colours.respond_to?(:string_italic)
    i.gsub(
      use_this_regex,
      ::Colours.string_italic('\1')+
      ::Colours.remove_trailing_escape_code(
        ::Colours.send(use_this_colour.to_sym, '')
      )
    )+::Colours.send(use_this_colour,'')
  else
    i
  end
end

#replace_regular_numbers_with_unicode_numbers(i) ⇒ Object

#

replace_regular_numbers_with_unicode_numbers

This method will replace numbers such as 1 with ¹.

#


1243
1244
1245
# File 'lib/studium/base/base.rb', line 1243

def replace_regular_numbers_with_unicode_numbers(i)
  ::Studium.replace_regular_numbers_with_unicode_numbers(i)
end

#replace_underline_token_with_default_colour(i, colour_to_use = :royalblue) ⇒ Object

#

replace_underline_token_with_default_colour

#


1589
1590
1591
# File 'lib/studium/base/base.rb', line 1589

def replace_underline_token_with_default_colour(i, colour_to_use = :royalblue)
  replace_underline_token_with_this_colour(i, colour_to_use)
end

#replace_underline_token_with_this_colour(i, use_this_colour = :royalblue) ⇒ Object

#

replace_underline_token_with_this_colour

We can use either <ud> or <u>, so we have to check for both variants.

#


1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
# File 'lib/studium/base/base.rb', line 1598

def replace_underline_token_with_this_colour(
    i, use_this_colour = :royalblue # This default colour is rarely in use.
  )
  if (i.include?('<ud>') and i.include?('</ud>')) or
     (i.include?('<u>')  and i.include?('</u>'))
    # ===================================================================== #
    # Next, set up a non-greedy explicit regex:
    #
    #   https://rubular.com/r/uNnBwWc35LKjXX
    #
    # ===================================================================== #
    use_this_regex = /<ud?>([-a-züöäA-ZÜÖÄ0-9\/%, \n\.]+?)<\/ud?>/
    i = i.dup if i.frozen?
    i.gsub!(
      use_this_regex,
      ::Colours.string_underline('\1')+
      ::Colours.remove_trailing_escape_code(
        ::Colours.send(use_this_colour.to_sym, '')
      )
    )
  end
  return i
end

#require_open_uriObject

#

require_open_uri

#


3166
3167
3168
# File 'lib/studium/base/base.rb', line 3166

def require_open_uri
  require 'open-uri'
end

#resetObject

#

reset (reset tag)

#


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
# File 'lib/studium/base/base.rb', line 136

def reset
  initialize_the_internal_hash # This should come first here.
  # ======================================================================= #
  # === :namespace
  # ======================================================================= #
  @internal_hash[:namespace] = NAMESPACE
  # ======================================================================= #
  # === :use_colours
  #
  # The next variable determines whether instances of this class will
  # make use of colours. By default the value from a toplevel-variable
  # will be used as default start value. Thus, initially, they have
  # the same value.
  # ======================================================================= #
  @internal_hash[:use_colours] = ::Studium.use_colours?
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  @internal_hash[:be_verbose] = true
  # ======================================================================= #
  # === :use_opn
  #
  # By default we will use opn in the project. The name "opn" stands
  # short for "output program name".
  # ======================================================================= #
  @internal_hash[:use_opn] = true
  # ======================================================================= #
  # === @debug
  #
  # The next variable determines whether we will debug or whether we
  # will not. If @debug is set to true, then we won't make modifications -
  # instead, we will give debug information to the user.
  # ======================================================================= #
  @internal_hash[:debug] = false
  # ======================================================================= #
  # === Determine the runmode to use for this class
  #
  # Next, determine which "mode" is used, such as www-mode, commandline
  # mode or similar.
  #
  # The :runmode variable can be any of these three values:
  #
  #   :commandline
  #   :www
  #   :gui
  #
  # If :commandline is used as its value, then this class may colourize via
  # the Colours module - otherwise, it may colourize via "websafe" colours
  # instead (such as the HTML colours).
  #
  # Note that :gui means GUI, that is, graphical user interface. These
  # are traditional "oldschool" desktop applications.
  # ======================================================================= #
  if Studium.runmode?
    set_runmode(Studium.runmode?)
  else
    set_runmode(:commandline) # The default mode is commandline.
  end
end

#reset_the_internal_stateObject

#

reset_the_internal_state

#


376
377
378
379
380
381
382
383
# File 'lib/studium/base/base.rb', line 376

def reset_the_internal_state
  # ======================================================================= #
  # === @internal_hash[:no_connection_to_the_www]
  #
  # If true then we have no connection to the WWW.
  # ======================================================================= #
  @internal_hash[:no_connection_to_the_www] = false
end

#return_all_bachelor_lectures(from_this_dataset = ::Studium.main_dataset?) ⇒ Object

#

return_all_bachelor_lectures

This method will simply return all bachelor-lectures.

#


2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
# File 'lib/studium/base/base.rb', line 2715

def return_all_bachelor_lectures(
    from_this_dataset = ::Studium.main_dataset?
  )
  if from_this_dataset.nil?
    ::Studium.initialize_main_dataset
    from_this_dataset = ::Studium.main_dataset?
  end
  from_this_dataset.select {|name_of_the_lecture, inner_hash|
    array = inner_hash['curricula']
    is_a_bachelor_lecture?(array)
  }
end

#return_all_exams_on_this_day(i) ⇒ Object

#

return_all_exams_on_this_day

#


1192
1193
1194
# File 'lib/studium/base/base.rb', line 1192

def return_all_exams_on_this_day(i)
  Studium.return_all_exams_on_this_day(i)
end

#return_all_numbers_from(i) ⇒ Object

#

return_all_numbers_from

This method will return all numbers from the given input.

#


524
525
526
527
528
529
530
531
532
# File 'lib/studium/base/base.rb', line 524

def return_all_numbers_from(i)
  return_this = nil
  if i.is_a? Array
    return_this = i.select {|line|
      line =~ /\d+/ # Any entry with a number will be returned.
    }
  end
  return_this
end

#return_all_registered_curriculaObject

#

return_all_registered_curricula

#


2655
2656
2657
# File 'lib/studium/base/base.rb', line 2655

def return_all_registered_curricula
  Studium.return_registered_standalone_curricula
end

#return_all_steop_lecturesObject

#

return_all_steop_lectures

#


537
538
539
540
541
542
# File 'lib/studium/base/base.rb', line 537

def return_all_steop_lectures
  return_sanitized_dataset_from_the_file_lecture_information.select {|a, b|
    is_a_steop_lecture = obtain(:steop, b)
    is_a_steop_lecture
  }
end

#return_current_yearObject Also known as: current_year?

#

return_current_year

This method will simply return the current year, as String.

#


2996
2997
2998
# File 'lib/studium/base/base.rb', line 2996

def return_current_year
  Time.now.year.to_s
end

#return_dataset_for_this_topic(i) ⇒ Object

#

return_dataset_for_this_topic

#


1250
1251
1252
# File 'lib/studium/base/base.rb', line 1250

def return_dataset_for_this_topic(i)
  Studium.return_dataset_for_this_topic(i)
end

#return_dataset_from_this_curriculum_file(i) ⇒ Object Also known as: return_dataset_for_this_curriculum_file, return_dataset_from_this_curriculum, return_this_curriculum

#

return_dataset_from_this_curriculum_file

#


2662
2663
2664
# File 'lib/studium/base/base.rb', line 2662

def return_dataset_from_this_curriculum_file(i)
  return Studium.return_dataset_from_this_curriculum_file(i)
end

#return_dd_mm_yy_and_time_from(i) ⇒ Object

#

return_dd_mm_yy_and_time_from

This method will return the day, in dd.mm.yyyy format, and the time on that date. You have to pass in a special object to this method, such as an instance of class Time - see methods used such as .day() or .month() and so forth.

#


3008
3009
3010
# File 'lib/studium/base/base.rb', line 3008

def return_dd_mm_yy_and_time_from(i)
  Studium.return_dd_mm_yy_and_time_from(i)
end

#return_directory_for(name_of_the_lecture, university) ⇒ Object

#

return_directory_for

This method will try to build up the most plausible, local path to an existing directory.

#


1301
1302
1303
1304
1305
1306
# File 'lib/studium/base/base.rb', line 1301

def return_directory_for(
    name_of_the_lecture,
    university
  )
  Studium.return_directory_for(name_of_the_lecture, university)
end

#return_ects_points_from_these_lectures(hash) ⇒ Object

#

return_ects_points_from_these_lectures

Input to this method should be a Hash containing our lectures.

An example for this is shown next:

{"051010"=>"Programmierung 1",
 "051110"=>"Mathematische Grundlagen der Informatik 1"}
#


910
911
912
913
914
915
916
917
918
919
920
921
922
# File 'lib/studium/base/base.rb', line 910

def return_ects_points_from_these_lectures(hash)
  n_ects_points = 0 # Keep track of the amount of ECTS points here.
  hash.each_pair {|lecture_id, name_of_the_lecture|
    # lecture_id = ensure_main_encoding(lecture_id)
    # name_of_the_lecture = ensure_main_encoding(name_of_the_lecture)
    name_of_the_lecture.squeeze!(' ')
    points = Studium.return_ects_from_this_lecture_stored_in_the_file_lecture_information(
      name_of_the_lecture, lecture_id
    )
    n_ects_points += points
  }
  return n_ects_points
end

#return_either_grey_or_the_custom_colour_for_answersObject

#

return_either_grey_or_the_custom_colour_for_answers

#


2861
2862
2863
2864
2865
2866
2867
2868
# File 'lib/studium/base/base.rb', line 2861

def return_either_grey_or_the_custom_colour_for_answers
  _ = grey('').strip
  if @internal_hash[:custom_colours] and
     @internal_hash[:custom_colours].has_key?('colour_for_answers')
    _ = COLOURS.send(@internal_hash[:custom_colours]['colour_for_answers']) { :omit_end }
  end
  return _
end

#return_either_grey_or_the_custom_colour_for_questions(custom_colours = ) ⇒ Object

#

return_either_grey_or_the_custom_colour_for_questions

#


3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
# File 'lib/studium/base/base.rb', line 3186

def return_either_grey_or_the_custom_colour_for_questions(
    custom_colours = @internal_hash[:custom_colours]
  )
  _ = grey('').strip
  if custom_colours and
     custom_colours.has_key?('colour_for_questions')
    _ = COLOURS.send(custom_colours['colour_for_questions']) { :omit_end }
  end
  return _
end

#return_file_for_this_curriculum(i = :bachelor_basisblock_biologie) ⇒ Object Also known as: return_curriculum_file_based_on_this_input, curriculum_location_of, return_path_of_this_curriculum, return_path_to_the_curriculum_file, return_file_associated_with_this_curriculum, location_of_this_curriculum_file?

#

return_file_for_this_curriculum

This method is a wrapper over the toplevel-method called Studium.return_file_for_this_curriculum().

#


1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
# File 'lib/studium/base/base.rb', line 1474

def return_file_for_this_curriculum(
    i = :bachelor_basisblock_biologie
  )
  if i.is_a? Array
    i.map {|line|
      return_file_for_this_curriculum(line)
    }
  else
    # ===================================================================== #
    #
    #   bl $RUBY_STUDIUM/constants/return_file_for_this_curriculum.rb
    #
    # ===================================================================== #
    Studium.return_file_for_this_curriculum(i)
  end
end

#return_german_name_for_this_english_month(i) ⇒ Object Also known as: to_german_month

#

return_german_name_for_this_english_month

#


2081
2082
2083
2084
# File 'lib/studium/base/base.rb', line 2081

def return_german_name_for_this_english_month(i)
  array = MONTH_NAME_ALIASES_GERMAN_TO_ENGLISH.invert
  return array[i]
end

#return_german_weekday_of?(i) ⇒ Boolean

#

return_german_weekday_of?

#

Returns:

  • (Boolean)


2074
2075
2076
# File 'lib/studium/base/base.rb', line 2074

def return_german_weekday_of?(i)
  weekday?(i, :german)
end

#return_hh_mm_ss_from(i = Time.now) ⇒ Object Also known as: hh_mm_ss

#

return_hh_mm_ss_from

Input to this method may be like this:

2020-03-04 00:00:00 +0000

It will then return the ss:mm:hh notation.

#


2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
# File 'lib/studium/base/base.rb', line 2947

def return_hh_mm_ss_from(i = Time.now)
  if i.is_a? String
    i = Time.parse(i)
  end
  if i.is_a? Time
    "#{i.hour.to_s.rjust(2,'0')}:"\
    "#{i.min.to_s.rjust(2,'0')}:"\
    "#{i.sec.to_s.rjust(2,'0')}"
  else
    e 'Unknown time format.'
  end
end

#return_hour_from_this(i) ⇒ Object Also known as: extract_the_time_from

#

return_hour_from_this

This method will extract the time-format from a String, such as:

"18.02.2020, 17:00-18:00"
"Dienstag 13.10.2020, 14:30-17:45"

A String will be returned in this event, holding the start and stop time - for instance, in the first example it would return the String “17:00-18:00”.

A String should be given as argument to this method.

#


2895
2896
2897
2898
2899
# File 'lib/studium/base/base.rb', line 2895

def return_hour_from_this(i)
  i.scan(
    /\d{2}:\d{2}-\d{2}:\d{2}/
  ).flatten.first.to_s.strip
end

#return_lectures_from_bachelor_vektor_curriculumObject

#

return_lectures_from_bachelor_vektor_curriculum

#


810
811
812
# File 'lib/studium/base/base.rb', line 810

def return_lectures_from_bachelor_vektor_curriculum
  obtain_lectures_from_this_curriculum(:bachelor_vektor)
end

#return_lectures_with_at_the_least_one_upcoming_examObject

#

return_lectures_with_at_the_least_one_upcoming_exam

This method will return all lectures that have at the least one upcoming exam entry. In this context “upcoming” refers to an exam date that comes after today (or any day before today).

#


2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
# File 'lib/studium/base/base.rb', line 2763

def return_lectures_with_at_the_least_one_upcoming_exam
  today = Time.now
  return_sanitized_dataset_from_the_file_lecture_information.select {|name_of_the_course, hash_dataset|
    if hash_dataset.has_key? 'exams'
      exams = hash_dataset['exams']
      if exams.is_a? Array
        exams = exams.first
      end
      exams = remove_german_weekdays(exams)
      exams.delete!(',')
      if exams.include? 'Ort:'
        exams = exams.split('Ort:').first.to_s
      end
      # =================================================================== #
      # The next line can be problematic, if the entry is incorrect.
      # Hence the rescue-clause.
      # =================================================================== #
      begin
        time_parsed = Time.parse(exams)
      rescue Exception => error
        pp error
        e rev+'The original input was: '+
           tomato(hash_dataset['exams'])
        e 'The modified input was: '+
           steelblue(exams)
        exit
      end
      today < time_parsed # Check that the courses are not too old.
    else
      false
    end
  }
end

#return_local_path_of_this_pwdstud(i = 1) ⇒ Object

#

return_local_path_of_this_pwdstud

#


2440
2441
2442
# File 'lib/studium/base/base.rb', line 2440

def return_local_path_of_this_pwdstud(i = 1)
  Studium.return_local_path_of_this_pwdstud(i)
end

#return_lva_number_of_this_lecture(this_lecture) ⇒ Object

#

return_lva_number_of_this_lecture

#


2369
2370
2371
# File 'lib/studium/base/base.rb', line 2369

def return_lva_number_of_this_lecture(this_lecture)
  ::Studium.return_lva_number_of_this_lecture(this_lecture)
end

#return_month_fitting_to_this_input(i) ⇒ Object

#

return_month_fitting_to_this_input

This method will return a number.

#


563
564
565
566
567
568
569
# File 'lib/studium/base/base.rb', line 563

def return_month_fitting_to_this_input(i)
  i = i.capitalize
  if MONTH_NAME_TO_MONTH_NUMBER.has_key? i
    i = MONTH_NAME_TO_MONTH_NUMBER[i]
  end
  return i.to_i
end

#return_n_days_until_monday(time_now = Time.now) ⇒ Object

#

return_n_days_until_monday

#


3269
3270
3271
3272
3273
# File 'lib/studium/base/base.rb', line 3269

def return_n_days_until_monday(
    time_now = Time.now
  )
  n_days_difference_from_today_to_this_day(time_now, 'Monday')
end

#return_n_days_until_sunday(time_now = Time.now) ⇒ Object

#

return_n_days_until_sunday

#


2985
2986
2987
2988
2989
# File 'lib/studium/base/base.rb', line 2985

def return_n_days_until_sunday(
    time_now = Time.now
  )
  n_days_difference_from_today_to_this_day(time_now, 'Sunday')
end

#return_n_exam_questions_in(this_topic) ⇒ Object

#

return_n_exam_questions_in

This method will return how many exam questions are in the given topic xyz.

#


2751
2752
2753
# File 'lib/studium/base/base.rb', line 2751

def return_n_exam_questions_in(this_topic)
  Studium::Exams.return_n_questions_in_this_topic(this_topic)
end

#return_n_questions_were_answered_for_this_topic(i) ⇒ Object

#

return_n_questions_were_answered_for_this_topic

#


867
868
869
# File 'lib/studium/base/base.rb', line 867

def return_n_questions_were_answered_for_this_topic(i)
  Studium::Exams.return_n_questions_were_answered_for_this_topic(i)
end

#return_name_of_the_weekday(i = :today) ⇒ Object Also known as: return_weekday

#

return_name_of_the_weekday

This method can be used to return an associated weekday to a specific date, such as ‘22.02.2018’. The format has to be in dd.mm.yyyy.

As mnemonic-helper, Roebe.return_german_weekday “22.11.2022” would yield the String “Dienstag”.

#


2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
# File 'lib/studium/base/base.rb', line 2534

def return_name_of_the_weekday(
    i = :today
  )
  begin
    require 'roebe/constants/time.rb'
  rescue LoadError; end
  case i
  # ======================================================================= #
  # === :today
  # ======================================================================= #
  when :today
    i = Roebe.return_german_weekday(i) if Object.const_defined? :Roebe
  end
  if i.include? ','
    splitted = i.split(',')
    first = splitted.first
    if first.count('.') > 1
      return Roebe.return_german_weekday(first) if Object.const_defined? :Roebe
    end
  else
    return i
  end
end

#return_name_of_this_curriculum(i) ⇒ Object Also known as: return_long_name_of_this_curriculum

#

return_name_of_this_curriculum

This method will return the official name of a curriculum. In order to achieve this, the method will read the file, and grab the second line, which should contain the name of the curriculum at hand.

This method will NOT remove strings such as “Bachelorcurriculum” or “Mastercurriculum”, due to the individual vector-curriculum having the very same name (Bachelor + Master).

#


2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
# File 'lib/studium/base/base.rb', line 2632

def return_name_of_this_curriculum(i)
  file = return_file_for_this_curriculum(i)
  if file.nil?
    e "Something went wrong for the input #{steelblue(i)}."
    e 'No match could be found for it. Are you sure that it must exist?'
    exit
  elsif File.exist? file
    dataset = readlines_with_proper_encoding(file)
    name = dataset[1].delete('#=').strip
    return name
  end
end

#return_name_of_this_curriculum_based_on_its_id_number(i) ⇒ Object Also known as: from_curriculum_id_to_curriculum_name, return_curriculum_name_of_this_curriculum_number, curriculum_number_to_curriculum_name, name_of_this_curriculum?, return_name_of_the_curriculum_based_on_this_curriculum_id, return_name_of_the_curriculum, turn_id_to_curriculum_name

#

return_name_of_this_curriculum_based_on_its_id_number

The input to this method should be the ID of a curriculum number, ideally as a String, such as ‘033290’.

#


2700
2701
2702
# File 'lib/studium/base/base.rb', line 2700

def return_name_of_this_curriculum_based_on_its_id_number(i)
  ::Studium.map_curriculum_number_to_curriculum_name(i)
end

#return_opnn(use_this_namespace = NAMESPACE) ⇒ Object Also known as: ropnn

#

return_opnn

#


1169
1170
1171
1172
1173
1174
1175
1176
# File 'lib/studium/base/base.rb', line 1169

def return_opnn(
    use_this_namespace = NAMESPACE
  )
  ::Colours::GREY+
  use_this_namespace+
  ': '+
  ::Colours::REVERT
end

#return_passed_coursesObject

#

return_passed_courses

This method will quickly return all passed courses.

#


892
893
894
895
896
897
# File 'lib/studium/base/base.rb', line 892

def return_passed_courses
  return_dataset_from_file_lecture_information.select {|key, hash|
    hash.has_key?(:already_solved) and
    (hash[:already_solved] == true)
  }
end

#return_pwdObject Also known as: pwd?

#

return_pwd

This method will return the current working directory.

#


294
295
296
# File 'lib/studium/base/base.rb', line 294

def return_pwd
  "#{Dir.pwd}/".squeeze('/')
end

#return_random_curriculumObject

#

return_random_curriculum

#


796
797
798
# File 'lib/studium/base/base.rb', line 796

def return_random_curriculum
  ::Studium.return_random_curriculum
end

#return_sanitized_dataset_from_the_file_lecture_informationObject Also known as: return_dataset_from_the_file_lecture_information, return_dataset_from_file_lecture_information, lecture_information_dataset, lecture_information, dataset_from_file_lecture_information, dataset_from_lecture_information, dataset_lecture_information, return_lecture_information, return_data_from_the_file_lecture_information, return_all_lectures, all_lectures?, return_lectures_from_file_lecture_information, dataset_from_the_file_lecture_information, return_sanitized_dataset_from_file_lecture_information, return_dataset_from_the_lectures, return_sanitized_dataset, return_all_lectures_from_the_file_lecture_information, return_dataset_from_lecture_information, from_file_lecture_information, sanitized_dataset_from_file_lecture_information

#

return_sanitized_dataset_from_the_file_lecture_information

This method will return the dataset stored in the file ‘lecture_information.yml’.

#


992
993
994
# File 'lib/studium/base/base.rb', line 992

def return_sanitized_dataset_from_the_file_lecture_information
  Studium.return_sanitized_dataset_from_the_file_lecture_information
end

#return_solved_lecturesObject

#

return_solved_lectures

This method will return only those entries that have the key :already_solved set to true.

#


1268
1269
1270
1271
1272
1273
# File 'lib/studium/base/base.rb', line 1268

def return_solved_lectures
  already_solved = select_lectures_with_this_key(:already_solved).select {|a,b|
    obtain(:already_solved, b) == true
  }
  already_solved
end

#return_steop_lectures(optional_ignore_already_completed_steop_lectures = true) ⇒ Object

#

return_steop_lectures (steop tag)

This method will return all registered STEOP lectures.

The optional argument will determine whether solved STEOP lectures will also be returned. By default this is not the case, meaning that we will ignore STEOP lectures that have already been solved.

#


1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
# File 'lib/studium/base/base.rb', line 1317

def return_steop_lectures(
    optional_ignore_already_completed_steop_lectures = true
  )
  if ::Studium.main_dataset?
    dataset = ::Studium.main_dataset?
  else
    dataset = return_dataset_from_the_file_lecture_information
  end
  selection = dataset.select {|a, b|
    b.has_key?(:is_a_steop_lecture) and (b[:is_a_steop_lecture] == true)
  }
  if optional_ignore_already_completed_steop_lectures
    selection = selection.reject {|a, b|
      b.has_key?(:already_solved) and (b[:already_solved] == true)
    }
  end
  return selection
end

#return_the_remote_homepage_url(of_this_lecture, dataset_to_use) ⇒ Object

#

return_the_remote_homepage_url

The first parameter denotes which particular lecture is to be investigated, in regards to its homepage-URL.

The second parameter should contain the hash-dataset that is to be used.

#


1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
# File 'lib/studium/base/base.rb', line 1404

def return_the_remote_homepage_url(
    of_this_lecture, dataset_to_use
  )
  of_this_lecture.strip!
  _ = dataset_to_use
  if _.has_key? :homepage
    _ = _[:homepage]
  else
    e "No :homepage entry for `#{sfancy(of_this_lecture.to_s)}`."
  end
  return _
end

#return_this_line_has_n_characters_as_html_colour_tags(i) ⇒ Object

#

return_this_line_has_n_characters_as_html_colour_tags

#


844
845
846
847
848
# File 'lib/studium/base/base.rb', line 844

def return_this_line_has_n_characters_as_html_colour_tags(i)
  i.scan(REGEX_FOR_OPENING_AND_CLOSING_COLOUR_TAGS).map {|entry|
    entry.size
  }.sum
end

#return_title_from_this_curriculum_file(i, use_a_shorter_name = false) ⇒ Object Also known as: return_title_of, return_pretty_title_of_this_curriculum, return_title_of_this_curriculum

#

return_title_from_this_curriculum_file

The first argument to this method should be the abbreviation of that particular curriculum.

Note that an Array can also be given as input to this method; this may be done if a curriculum consists of more than one block.

Usage example:

return_title_from_this_curriculum_file(:indi2)
#


1535
1536
1537
1538
1539
1540
# File 'lib/studium/base/base.rb', line 1535

def return_title_from_this_curriculum_file(
    i,
    use_a_shorter_name = false
  )
  Studium.return_title_from_this_curriculum_file(i, use_a_shorter_name)
end

#right_arrow?Boolean Also known as: right_arrow, rarrow, rarrow?

#

right_arrow?

#

Returns:

  • (Boolean)


1804
1805
1806
# File 'lib/studium/base/base.rb', line 1804

def right_arrow?
  UNICODE_RIGHT_ARROW
end

#rinstall2Object Also known as: r2

#

rinstall2

This method can be used to perform an install-process via oldschool setup.rb.

#


2092
2093
2094
2095
2096
2097
2098
2099
2100
# File 'lib/studium/base/base.rb', line 2092

def rinstall2
  cpruby
  system 'ruby setup.rb --quiet config'
  system 'ruby setup.rb --quiet setup'
  system 'ruby setup.rb --quiet install'
  delete_file 'setup.rb'
  delete_file 'InstalledFiles'
  delete_file '.config'
end

#roebe_exam_directory?Boolean

#

roebe_exam_directory?

#

Returns:

  • (Boolean)


1625
1626
1627
# File 'lib/studium/base/base.rb', line 1625

def roebe_exam_directory?
  "#{RUBY_STUDIUM_HOME_DIR}exam_topics/"
end

#roebe_path_to_file_lecture_information?Boolean

#

roebe_path_to_file_lecture_information?

#

Returns:

  • (Boolean)


1910
1911
1912
1913
# File 'lib/studium/base/base.rb', line 1910

def roebe_path_to_file_lecture_information?
  '/home/x/programming/ruby/src/studium/lib/studium/yaml/lecture_information/'\
  'lecture_information.yml'
end

#ruby_src_dir_at_home?Boolean

#

ruby_src_dir_at_home?

#

Returns:

  • (Boolean)


1368
1369
1370
# File 'lib/studium/base/base.rb', line 1368

def ruby_src_dir_at_home?
  Studium.ruby_src_dir_at_home?
end

#runObject

#

run

#


3527
3528
# File 'lib/studium/base/base.rb', line 3527

def run
end

#sanitize_this_topic(this_topic) ⇒ Object

#

sanitize_this_topic (sanitize tag, alias tag)

This entry keeps all possible aliases to commonly used topics, in particular abbreviations.

#


1234
1235
1236
# File 'lib/studium/base/base.rb', line 1234

def sanitize_this_topic(this_topic)
  Studium.sanitize_this_theme_topic(this_topic)
end

#sanitize_url(i, optional_extra_modes = nil) ⇒ Object Also known as: sanitized_url

#

sanitize_url

This is such a useful method that we will use it for all subclasses of Studium::Base.

#


1281
1282
1283
1284
1285
1286
# File 'lib/studium/base/base.rb', line 1281

def sanitize_url(
    i,
    optional_extra_modes = nil
  )
  Studium.sanitize_url(i, optional_extra_modes)
end

#select_for_prüfungsimmanente_LVs(i) ⇒ Object

#

select_for_prüfungsimmanente_LVs

We assume the input to this method is a Hash containing all lectures.

#


1827
1828
1829
1830
1831
1832
# File 'lib/studium/base/base.rb', line 1827

def select_for_prüfungsimmanente_LVs(i)
  i.select {|name_of_the_course, inner_hash|
    type = inner_hash[:type]
    is_prüfungsimmanent?(type)
  }
end

#select_lectures_with_this_key(searching_for_this_key) ⇒ Object

#

select_lectures_with_this_key

This method allows us to select only entries with a particular key. The key has to be passed to the method and - for now - has to be exactly the same as the key (e. g. string for strings and symbols for symbols; no automatic conversions for now).

The advantage of this method is that it will simplify a lot of code; all code that requires us to select only specific lectures.

Usage examples:

.select_lectures_with_this_key(:exam_registration_at)
.select_lectures_with_this_key(:already_solved)
#


942
943
944
945
946
947
948
949
950
# File 'lib/studium/base/base.rb', line 942

def select_lectures_with_this_key(
    searching_for_this_key
  )
  dataset = return_sanitized_dataset_from_the_file_lecture_information
  dataset.select! {|name_of_the_lecture, inner_hash|
    inner_hash.has_key? searching_for_this_key
  } if dataset # <- Must check here, since there may be a nil.
  return dataset
end

#set_be_verboseObject Also known as: be_verbose

#

set_be_verbose

#


469
470
471
# File 'lib/studium/base/base.rb', line 469

def set_be_verbose
  @internal_hash[:be_verbose] = true
end

#set_this_cd_alias_to(cd_alias, new_content, be_verbose = :default) ⇒ Object

#

set_this_cd_alias_to

#


1181
1182
1183
1184
1185
1186
1187
# File 'lib/studium/base/base.rb', line 1181

def set_this_cd_alias_to(
    cd_alias,
    new_content,
    be_verbose = :default
  )
  Studium.set_this_cd_alias_to(cd_alias, new_content, be_verbose)
end

#set_xorg_buffer(i) ⇒ Object

#

set_xorg_buffer

#


631
632
633
634
635
636
637
638
639
640
# File 'lib/studium/base/base.rb', line 631

def set_xorg_buffer(i)
  begin
    require 'xorg_buffer' unless Object.const_defined?(:XorgBuffer)
    XorgBuffer.set_buffer(i)
  rescue LoadError
    if is_on_roebe?
      e 'XorgBuffer is not available - can not set the buffer.'
    end
  end
end

#sfancy(i = '', use_colours = use_colours? ) ⇒ Object

#

sfancy

#


234
235
236
237
238
239
240
# File 'lib/studium/base/base.rb', line 234

def sfancy(
    i            = '',
    use_colours = use_colours?
  )
  return ::Colours.sfancy(i) if use_colours
  return i
end

#shall_we_make_use_of_unicode_symbols?Boolean Also known as: use_unicode_symbols?, use_unicode?

#

shall_we_make_use_of_unicode_symbols?

The most common idiom for using this method is actually via:

if use_unicode_symbols?
#

Returns:

  • (Boolean)


1703
1704
1705
# File 'lib/studium/base/base.rb', line 1703

def shall_we_make_use_of_unicode_symbols?
  ::Studium.shall_we_make_use_of_unicode_symbols?
end

#show_todays_dateObject

#

show_todays_date

#


2173
2174
2175
2176
# File 'lib/studium/base/base.rb', line 2173

def show_todays_date
  e "Today is the #{slateblue(today?)} (#{lightgreen(weekday?)})"
  e
end

#silently_open_in_browser(into) ⇒ Object

#

silently_open_in_browser

This method can accept Strings such as ‘/home/x/Temp/studium/html/timetable.html#today’.

#


2108
2109
2110
2111
# File 'lib/studium/base/base.rb', line 2108

def silently_open_in_browser(into)
  try_to_require_the_open_gem unless Object.const_defined?(:Open)
  ::Open.in_browser(into) { :be_silent }
end

#simp(i = '', use_colours = use_colours? ) ⇒ Object

#

simp

#


223
224
225
226
227
228
229
# File 'lib/studium/base/base.rb', line 223

def simp(
    i           = '',
    use_colours = use_colours?
  )
  return ::Colours.simp(i) if use_colours # Delegate to module Colours in this case.
  return i
end

#sort_these_lecture_names_by_time(array, weekday) ⇒ Object

#

sort_these_lecture_names_by_time

#


2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
# File 'lib/studium/base/base.rb', line 2904

def sort_these_lecture_names_by_time(
    array, weekday
  )
  _ = main_dataset?
  array.sort_by {|entry|
    pointer = _[entry]
    lva_date = pointer['lva_dates'].select {|inner_entry|
      inner_entry.include? weekday
    }
    lva_date = lva_date.first if lva_date.is_a? Array
    lva_date = return_hour_from_this(lva_date) # This will be like "08:00-09:45"
    # ===================================================================== #
    # However had, we only need the last part, so chop it down.
    # ===================================================================== #
    if lva_date.include? '-'
      lva_date = lva_date.split('-').first
    end
    timestamp = Time.parse(lva_date)
    timestamp # And "return" it here.
  }
end

#spacerObject

#

spacer

#


417
418
419
# File 'lib/studium/base/base.rb', line 417

def spacer
  Studium.spacer
end

#studium_log_dir?Boolean Also known as: log_dir?, base_dir?

#

studium_log_dir?

This is the log dir - where we “operate on”.

#

Returns:

  • (Boolean)


2875
2876
2877
# File 'lib/studium/base/base.rb', line 2875

def studium_log_dir?
  Studium.log_dir?
end

#this_month_has_n_days?(this_month, this_year = Time.now.year) ⇒ Boolean

#

this_month_has_n_days?

This method will return the maximum amount of days in the given month.

#

Returns:

  • (Boolean)


2973
2974
2975
2976
2977
2978
2979
2980
# File 'lib/studium/base/base.rb', line 2973

def this_month_has_n_days?(
    this_month,
    this_year = Time.now.year
  )
  this_month = this_month.to_i
  return 29 if this_month == 2 && Date.gregorian_leap?(this_year)
  COMMON_YEAR_DAYS_IN_MONTH[this_month] 
end

#total_ects_points_passed(i) ⇒ Object

#

total_ects_points_passed

#


1547
1548
1549
# File 'lib/studium/base/base.rb', line 1547

def total_ects_points_passed(i)
  Studium.total_ects_points_passed(i)
end

#translate_dd_mm_yyyy_to_weekday(i = '25.02.2020') ⇒ Object Also known as: translate_dd_mm_yyy_to_weekday

#

translate_dd_mm_yyyy_to_weekday

This method will return the weekday of a given dd.mm.yyyy date.

If the given input is, for example, the String ‘25.02.2019’, then this method will return the String ‘Monday’.

#


2397
2398
2399
2400
2401
# File 'lib/studium/base/base.rb', line 2397

def translate_dd_mm_yyyy_to_weekday(
    i = '25.02.2020'
  )
  weekday?(i)
end

#try_to_require_html_templatesObject

#

try_to_require_html_templates

#


1983
1984
1985
1986
1987
1988
# File 'lib/studium/base/base.rb', line 1983

def try_to_require_html_templates
  begin
    require 'cyberweb/requires/require_the_html_template.rb'
  rescue LoadError
  end
end

#try_to_require_the_open_gemObject

#

try_to_require_the_open_gem

#


1901
1902
1903
1904
1905
# File 'lib/studium/base/base.rb', line 1901

def try_to_require_the_open_gem
  begin
    require 'open'
  rescue LoadError; end
end

#try_to_require_the_rcfilesObject

#

try_to_require_the_rcfiles

#


609
610
611
612
613
# File 'lib/studium/base/base.rb', line 609

def try_to_require_the_rcfiles
  begin
    require 'rcfiles'
  rescue LoadError; end
end

#try_to_require_the_verbose_truth_gemObject

#

try_to_require_the_verbose_truth_gem

#


1973
1974
1975
1976
1977
1978
# File 'lib/studium/base/base.rb', line 1973

def try_to_require_the_verbose_truth_gem
  begin
    require 'verbose_truth'
  rescue LoadError
  end
end

#turn_this_array_into_the_full_dataset(i, use_this_dataset) ⇒ Object

#

turn_this_array_into_the_full_dataset

This method accepts an Array of lectures that will be replaced with a full dataset.

#


696
697
698
699
700
701
702
703
704
705
# File 'lib/studium/base/base.rb', line 696

def turn_this_array_into_the_full_dataset(
    i, use_this_dataset
  )
  hash = {}
  i.flatten.each {|name_of_the_lecture|
    pointer = use_this_dataset[name_of_the_lecture]
    hash[name_of_the_lecture] = pointer
  }
  hash
end

#unicode_blocks_line(optional_use_this_colour = nil, use_n_tokens = :default, use_this_unicode_token = :upper_half_block) ⇒ Object

#

unicode_blocks_line

This method will “draw” a (horizontal) unicode-blocks line, that is, a line that is “built” from unicode blocks.

The optional first argument can be used to use a specific colour.

Usage examples:

unicode_blocks_line :steelblue
unicode_blocks_line(:steelblue) {{ n_tokens: 84 }}
#


1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
# File 'lib/studium/base/base.rb', line 1722

def unicode_blocks_line(
    optional_use_this_colour = nil,
    use_n_tokens             = :default, # <- This defaults to 78.
    use_this_unicode_token   = :upper_half_block
  )
  case use_n_tokens
  when :default # Must come before we check for a given block.
    use_n_tokens = 78
  end
  if block_given?
    yielded = yield
    if yielded.is_a? Hash
      if yielded.has_key? :n_tokens
        use_n_tokens = yielded.delete(:n_tokens)
      end
    end
  end
  begin
    require 'roebe/toplevel_methods/unicode/unicode_block_elements.rb'
  rescue LoadError; end
  _ = (Roebe.send(use_this_unicode_token) * use_n_tokens)
  if optional_use_this_colour
    _ = ::Studium::Colours.send(optional_use_this_colour, _)
  end
  return _
end

#use_colours?Boolean

#

use_colours?

#

Returns:

  • (Boolean)


369
370
371
# File 'lib/studium/base/base.rb', line 369

def use_colours?
  @internal_hash[:use_colours]
end

#use_opn?Boolean

#

use_opn?

#

Returns:

  • (Boolean)


1429
1430
1431
# File 'lib/studium/base/base.rb', line 1429

def use_opn?
  @internal_hash[:use_opn]
end

#vertical_bar?Boolean

#

vertical_bar?

#

Returns:

  • (Boolean)


1684
1685
1686
# File 'lib/studium/base/base.rb', line 1684

def vertical_bar?
  return '|'
end

#web_liner(this_token = '*') ⇒ Object

#

web_liner

#


1291
1292
1293
# File 'lib/studium/base/base.rb', line 1291

def web_liner(this_token = '*')
  (this_token * 80)+N
end

#weekday?(i = Date.today.wday, use_this_language = :english) ⇒ Boolean Also known as: return_name_for_this_day, return_weekday_for, return_weekday_of, return_weekday_from_this_input, english_weekday, english_weekday?

#

weekday?

This method will return a String such as “Thursday”. Note that the english name will be returned by default. This can be changed via the second parameter to this method, which can be either :english or :german.

The input to this method should be a number, such as can be obtained via the method .wday().

A String can also be passed into this method, in a form like “dd.mm.yyyy”. So, an input String such as “10.03.2018” is perfectly valid.

#

Returns:

  • (Boolean)


3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
# File 'lib/studium/base/base.rb', line 3121

def weekday?(
    i                 = Date.today.wday,
    use_this_language = :english
  )
  if i.is_a?(String) and i.include?('.')
    # ===================================================================== #
    # In this case here assume an input-String such as "12.03.2018".
    # ===================================================================== #
    begin
      i = Time.parse(i).wday
    rescue ArgumentError => error
      pp error
    end
  end
  result = Date::DAYNAMES[i]
  case use_this_language
  # ======================================================================= #
  # === :german
  # ======================================================================= #
  when :german,
       :use_german
    # ===================================================================== #
    # In this case we have to translate to the german name.
    # ===================================================================== #
    result = ENGLISH_TO_GERMAN_WEEKDAYS[result]
  end
  return result
end

#weekdays?Boolean

#

weekdays?

This method will return all weekdays, as Array, including german and english names for these weekdays.

#

Returns:

  • (Boolean)


599
600
601
602
603
604
# File 'lib/studium/base/base.rb', line 599

def weekdays?
  (
    ARRAY_GERMAN_WEEKDAYS+
    HASH_SHORT_TO_LONG_WEEKDAYS.values
  ).flatten
end

#word_wrap(text, line_width = N_CHARACTERS_PER_LINE) ⇒ Object

#

word_wrap

This method can re-arrange a given text (a String) to honour a certain size limit, such as 80 characters per line.

Keep in mind that colours that may be used inside of a tag, such as <tomato>foobar</tomato>, will also count for that limit. This has to be remembered when doing the calculation for text-wrapping.

#


3517
3518
3519
3520
3521
3522
# File 'lib/studium/base/base.rb', line 3517

def word_wrap(
    text,
    line_width = N_CHARACTERS_PER_LINE
  )
  ::Studium.word_wrap(text, line_width)
end

#write_what_into(what, into, &block) ⇒ Object Also known as: store_what_into

#

write_what_into

Use this method to save data into a specific file.

#


3175
3176
3177
3178
3179
3180
3181
# File 'lib/studium/base/base.rb', line 3175

def write_what_into(
    what,
    into,
    &block
  )
  Studium.write_what_into(what, into, &block)
end

#www_connection_is_unavailableObject Also known as: www_is_unavailable

#

www_connection_is_unavailable

#


388
389
390
# File 'lib/studium/base/base.rb', line 388

def www_connection_is_unavailable
  @internal_hash[:no_connection_to_the_www] = true
end

#yaml_dir?Boolean

#

yaml_dir?

#

Returns:

  • (Boolean)


276
277
278
# File 'lib/studium/base/base.rb', line 276

def yaml_dir?
  Studium.yaml_directory?
end

#yellowrev(i) ⇒ Object

#

yellowrev

#


216
217
218
# File 'lib/studium/base/base.rb', line 216

def yellowrev(i)
  "#{yellow(i)}#{rev}"
end

#yes_or_no(i) ⇒ Object

#

yes_or_no

#


343
344
345
346
347
348
349
350
# File 'lib/studium/base/base.rb', line 343

def yes_or_no(i)
  case i
  when true
    'yes'
  when false
    'no'
  end
end