Class: Studium::Base
Overview
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
-
#add_proper_year_entry_to_this_line(line) ⇒ Object
# === add_proper_year_entry_to_this_line.
-
#already_solved_this_lva_number?(i) ⇒ Boolean
# === already_solved_this_lva_number? ========================================================================= #.
-
#append_what_into(what, into) ⇒ Object
# === append_what_into (append tag).
-
#available_topics_as_short_name ⇒ Object
(also: #available_topics?, #exam_topics?, #return_all_exam_topics, #available_exam_topics?)
# === available_topics_as_short_name ========================================================================= #.
-
#average_grade(i = :default, round_to = 2) ⇒ Object
# === average_grade ========================================================================= #.
-
#bachelor_master_or_diploma(this_lecture, dataset = nil) ⇒ Object
# === bachelor_master_or_diploma.
-
#be_silent ⇒ Object
(also: #be_quiet)
# === be_silent ========================================================================= #.
-
#be_verbose? ⇒ Boolean
# === be_verbose? ========================================================================= #.
-
#beautiful_url(i) ⇒ Object
(also: #return_remote_URL)
# === beautiful_url.
-
#change_directory(i = Dir.pwd) ⇒ Object
(also: #cd)
# === change_directory ========================================================================= #.
-
#cheering_person ⇒ Object
(also: #cheering_person?, #cheering_dude?)
# === cheering_person ========================================================================= #.
-
#chmod(new_mode = 0644, which_file = 'LINKS.md') ⇒ Object
# === chmod.
-
#cliner(which_token_to_use = :default_token, use_this_colour = nil, &block) ⇒ Object
# === cliner (cliner tag).
-
#colour_for_ects_points(i = '') ⇒ Object
(also: #colourize_ects, #colour_ects)
# === colour_for_ects_points ========================================================================= #.
-
#colourize_percentage(i) ⇒ Object
# === colourize_percentage.
-
#convert_this_array_of_lectures_into_the_full_dataset(i) ⇒ Object
# === convert_this_array_of_lectures_into_the_full_dataset.
-
#copy(from, to) ⇒ Object
(also: #copy_file)
# === copy (copy tag) ========================================================================= #.
-
#course_filter(dataset = dataset?, , filter_how = :BOKU) ⇒ Object
# === course_filter.
-
#cpruby ⇒ Object
# === cpruby ========================================================================= #.
-
#create_directory(i) ⇒ Object
(also: #mkdir)
# === create_directory ========================================================================= #.
-
#create_file(i) ⇒ Object
(also: #touch)
# === create_file ========================================================================= #.
-
#csv_file? ⇒ Boolean
# === csv_file?.
-
#current_month? ⇒ Boolean
(also: #month?, #return_current_month_as_a_number)
# === current_month?.
-
#current_semester? ⇒ Boolean
# === current_semester?.
-
#dataset? ⇒ Boolean
# === dataset?.
-
#datum? ⇒ Boolean
# === datum? ========================================================================= #.
-
#day_month_year(use_this_time = Time.now) ⇒ Object
(also: #today?, #return_day_month_year, #dd_mm_yyyy, #return_dd_mm_yyyy, #time_today)
# === day_month_year.
-
#debug? ⇒ Boolean
# === debug? ========================================================================= #.
-
#delete_file(i) ⇒ Object
# === delete_file ========================================================================= #.
-
#directory_of_the_exam_topics? ⇒ Boolean
# === directory_to_the_exam_topics? ========================================================================= # === directory_of_the_exam_topics?.
-
#directory_to_my_exam_topics ⇒ Object
# === directory_to_my_exam_topics ========================================================================= #.
-
#directory_to_the_exam_topics? ⇒ Boolean
(also: #exam_topics_directory?, #exam_topic_directory?)
# === directory_to_the_exam_topics?.
-
#disable_colours ⇒ Object
(also: #no_colours)
# === disable_colours ========================================================================= #.
-
#disable_colours_globally ⇒ Object
# === disable_colours_globally.
-
#do_not_be_verbose ⇒ Object
(also: #set_be_quiet)
# === do_not_be_verbose ========================================================================= #.
-
#do_not_use_opn ⇒ Object
# === do_not_use_opn ========================================================================= #.
-
#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).
-
#does_this_line_include_a_german_weekday?(i) ⇒ Boolean
(also: #does_this_string_include_a_german_weekday?)
# === does_this_line_include_a_german_weekday? ========================================================================= #.
-
#does_this_line_include_a_html_colour?(i) ⇒ Boolean
# === does_this_line_include_a_html_colour? ========================================================================= #.
-
#does_this_line_include_an_english_weekday?(i) ⇒ Boolean
# === does_this_line_include_an_english_weekday? ========================================================================= #.
-
#does_this_line_start_with_a_german_weekday?(i) ⇒ Boolean
# === does_this_line_start_with_a_german_weekday? ========================================================================= #.
-
#e(i = '') ⇒ Object
# === e (e tag) ========================================================================= #.
-
#ecomment(i = '', use_colours = use_colours? ) ⇒ Object
-
#editor? ⇒ Boolean
# === editor? ========================================================================= #.
-
#ee(i = '') ⇒ Object
# === ee (ee tag).
-
#egrey(i) ⇒ Object
# === egrey ========================================================================= #.
-
#enable_colours ⇒ Object
# === enable_colours ========================================================================= #.
-
#enable_colours_globally ⇒ Object
# === enable_colours_globally ========================================================================= #.
-
#enable_debug ⇒ Object
(also: #do_debug)
# === enable_debug ========================================================================= #.
-
#encoding? ⇒ Boolean
(also: #main_encoding?, #main_encoding_to_use?, #use_this_encoding?, #encoding_to_use?)
# === encoding?.
-
#english_to_german_weekday(english_day) ⇒ Object
(also: #english_to_german)
# === english_to_german_weekday.
-
#ensure_that_a_base_directory_exists_for_this_file(i) ⇒ Object
# === ensure_that_a_base_directory_exists_for_this_file.
-
#ensure_that_the_log_directory_exists ⇒ Object
# === ensure_that_the_log_directory_exists.
-
#eparse(i, use_colours = use_colours? ) ⇒ Object
(also: #ecolourize)
# === eparse.
-
#esystem(i) ⇒ Object
# === esystem ========================================================================= #.
-
#etomato(i) ⇒ Object
# === etomato ========================================================================= #.
-
#exit_program(make_newline = :no_newline) ⇒ Object
# === exit_program (exit tag).
-
#extract_dd_mm_yyyy(i) ⇒ Object
(also: #extract_ddmmyyyy)
-
#fetch_this_curriculum(i, &block) ⇒ Object
# === fetch_this_curriculum.
-
#file_important_exams? ⇒ Boolean
# === file_important_exams? ========================================================================= #.
-
#file_lecture_information? ⇒ Boolean
-
#file_passed_exams_per_month ⇒ Object
(also: #passed_exams_per_month, #local_csv_file?)
# === file_passed_exams_per_month ========================================================================= #.
-
#file_read_with_proper_encoding(this_file) ⇒ Object
# === file_read_with_proper_encoding ========================================================================= #.
-
#filter_away_already_answered_questions(i) ⇒ Object
(also: #filter_away_already_answered_comments)
# === filter_away_already_answered_questions ========================================================================= #.
-
#filter_away_invalid_questions(i) ⇒ Object
# === filter_away_invalid_questions.
-
#filter_for_all_passed_exams(i) ⇒ Object
# === filter_for_all_passed_exams ========================================================================= #.
-
#find_corresponding_exam_topic(i, be_verbose = be_verbose? ) ⇒ Object
(also: #return_file_associated_with_this_exam_topic, #find_corresponding_exam_title, #expand_topic, #try_to_find_a_registered_exam_topic)
# === find_corresponding_exam_topic.
-
#from_curriculum_id_to_university(id) ⇒ Object
(also: #from_curriculum_number_to_university, #which_university?)
# === from_curriculum_id_to_university.
-
#german_date_notation(i, use_this_token_as_separator = '-') ⇒ Object
(also: #german_notation, #to_german_date, #german_formatting_for_the_date)
# === german_date_notation.
-
#german_weekday?(i = Date.today.wday) ⇒ Boolean
(also: #weekday_at, #german_weekday)
# === german_weekday?.
-
#german_weekdays? ⇒ Boolean
# === german_weekdays? ========================================================================= #.
-
#german_weekend_for?(i = '22.11.2022') ⇒ Boolean
# === german_weekend_for? ========================================================================= #.
-
#german_yes_or_no(i) ⇒ Object
# === german_yes_or_no ========================================================================= #.
-
#has_a_bachelor_and_a_master_curriculum?(i) ⇒ Boolean
# === has_a_bachelor_and_a_master_curriculum? ========================================================================= #.
-
#has_a_bachelor_curriculum?(array) ⇒ Boolean
(also: #has_a_bachelor_curriculum_entry?, #is_a_bachelor_lecture?, #is_a_bachelor_curriculum?, #does_this_include_a_bachelor_curriculum?)
# === has_a_bachelor_curriculum?.
-
#has_a_master_curriculum?(array) ⇒ Boolean
(also: #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?.
-
#has_lva_dates_registered?(i) ⇒ Boolean
(also: #has_any_lva_dates_registered?)
# === has_lva_dates_registered? ========================================================================= #.
-
#has_this_exam_topic_been_solved?(i) ⇒ Boolean
# === has_this_exam_topic_been_solved? ========================================================================= #.
-
#has_year_entry?(this_line) ⇒ Boolean
(also: #this_line_has_a_year_entry?)
# === has_year_entry?.
-
#hh_mm_ss_dd_mm_yyyy(i) ⇒ Object
# === hh_mm_ss_dd_mm_yyyy ========================================================================= #.
-
#horizontal_bar? ⇒ Boolean
# === horizontal_bar? ========================================================================= #.
-
#html_log_directory? ⇒ Boolean
(also: #html_log_dir?)
# === html_log_dir? ========================================================================= #.
-
#infer_the_namespace ⇒ Object
# === infer_the_namespace.
-
#initialize_the_internal_hash ⇒ Object
(also: #reset_the_internal_hash)
# === initialize_the_internal_hash ========================================================================= #.
-
#internal_hash? ⇒ Boolean
(also: #ihash?)
# === internal_hash? ========================================================================= #.
-
#is_a_master_lecture?(i) ⇒ Boolean
# === is_a_master_lecture? ========================================================================= #.
-
#is_a_registered_curriculum?(i) ⇒ Boolean
# === is_a_registered_curriculum?.
-
#is_a_weekday?(i = 'Montag') ⇒ Boolean
# === is_a_weekday?.
-
#is_connected_to_the_www? ⇒ Boolean
# === is_connected_to_the_www? ========================================================================= #.
-
#is_german_weekday?(i) ⇒ Boolean
# === is_german_weekday? ========================================================================= #.
-
#is_on_roebe? ⇒ Boolean
(also: #is_roebe?, #on_roebe?)
# === is_on_roebe? ========================================================================= #.
-
#is_prüfungsimmanent?(i, ignore_these_types = nil) ⇒ Boolean
(also: #is_a_prüfungsimmanent_course?, #is_this_a_prüfungsimment_course?, #is_this_a_prüfungsimmanent_course?)
# === is_prüfungsimmanent?.
-
#is_this_a_registered_exam_topic?(i) ⇒ Boolean
# === is_this_a_registered_exam_topic?.
-
#is_this_a_valid_html_colour?(i) ⇒ Boolean
(also: #is_this_colour_a_html_colour?)
# === is_this_a_valid_html_colour?.
-
#is_this_day_today?(i = '18.02.2022') ⇒ Boolean
# === is_this_day_today?.
-
#is_this_lecture_a_practical_course?(this_lecture, optional_lecture_type = nil) ⇒ Boolean
(also: #is_this_lecture_a_practical_course, #is_it_a_practical_course?)
# === is_this_lecture_a_practical_course? ========================================================================= #.
-
#konsole_support? ⇒ Boolean
# === konsole_support? ========================================================================= #.
-
#last_file? ⇒ Boolean
# === last_file? ========================================================================= #.
-
#lectures_from_indi1 ⇒ Object
# === lectures_from_indi1 ========================================================================= #.
-
#lectures_from_indi2 ⇒ Object
# === lectures_from_indi2 ========================================================================= #.
-
#lectures_from_indi3 ⇒ Object
# === lectures_from_indi3 ========================================================================= #.
-
#lectures_from_indi4 ⇒ Object
# === lectures_from_indi4 ========================================================================= #.
-
#lectures_from_the_bachelor_genetik_curriculum ⇒ Object
# === lectures_from_the_bachelor_genetik_curriculum ========================================================================= #.
-
#lectures_from_the_individual_vektor_curricula ⇒ Object
# === lectures_from_the_individual_vektor_curricula.
-
#left_arrow? ⇒ Boolean
(also: #left_arrow)
# === left_arrow ========================================================================= #.
-
#load_yaml_dataset(i, do_rescue = false) ⇒ Object
# === load_yaml_dataset.
-
#map_input_to_this_curriculum_filename(i) ⇒ Object
-
#move_file(this_file, target) ⇒ Object
# === move_file ========================================================================= #.
-
#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.
-
#n_seconds_to_n_days(i) ⇒ Object
# === n_seconds_to_n_days.
-
#namespace? ⇒ Boolean
# === namespace? ========================================================================= #.
-
#no_ext_name(i) ⇒ Object
# === no_ext_name.
-
#no_file_exists_at(i) ⇒ Object
(also: #no_file_at)
# === no_file_exists_at ========================================================================= #.
-
#number_to_month(i) ⇒ Object
# === number_to_month.
-
#obtain(this_key, hash, be_verbose = true) ⇒ Object
(also: #obtain_this_value_from_hash, #obtain_from)
# === obtain (obtain tag).
-
#obtain_lectures_from_this_curriculum(i = :default, do_flatten_the_result = true) ⇒ Object
(also: #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.
-
#open_in_browser(i) ⇒ Object
# === open_in_browser ========================================================================= #.
-
#open_in_editor(i) ⇒ Object
# === open_in_editor ========================================================================= #.
-
#opne(i) ⇒ Object
# === opne ========================================================================= #.
-
#opnerev(i) ⇒ Object
# === opnerev ========================================================================= #.
-
#opnn(i = namespace?, , &block) ⇒ Object
# === opnn.
-
#padded_current_month?(i = current_month? ) ⇒ Boolean
# === padded_current_month? ========================================================================= #.
-
#parse_dd_mm_yyyy(i = '03.05.2023') ⇒ Object
# === parse_dd_mm_yyyy ========================================================================= #.
-
#parse_this_line_for_date_entry(i) ⇒ Object
# === parse_this_line_for_date_entry ========================================================================= #.
-
#path_to_exam_topic? ⇒ Boolean
# === directory_to_the_exam_topics? ========================================================================= # === path_to_exam_topic?.
-
#project_yaml_directory? ⇒ Boolean
# === project_yaml_directory? ========================================================================= #.
-
#rds(i) ⇒ Object
# === rds ========================================================================= #.
-
#read_dataset_from_a_curriculum_file(i, optional_commands = :remove_comments) ⇒ Object
# === read_dataset_from_a_curriculum_file ========================================================================= #.
-
#read_in_exam_dataset_from_this_file(this_file, shall_we_filter_away_invalid_questions = true, &block) ⇒ Object
(also: #obtain_exam_questions_from_this_file)
# === read_in_exam_dataset_from_this_file.
-
#read_this_file_with_default_encoding(this_file) ⇒ Object
(also: #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.
-
#readlines_from_this_input_file(this_file, use_this_encoding = :default_encoding, &block) ⇒ Object
(also: #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)
-
#register_sigint ⇒ Object
# === register_sigint ========================================================================= #.
-
#remove_empty_strings(i) ⇒ Object
# === remove_empty_strings.
-
#remove_escape_sequences(i) ⇒ Object
# === remove_escape_sequences ========================================================================= #.
-
#remove_internal_comments(i) ⇒ Object
-
#remove_leading_comments(i) ⇒ Object
-
#remove_leading_weekday_names_from(i) ⇒ Object
(also: #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.
-
#remove_newlines(i) ⇒ Object
# === remove_newlines.
-
#remove_tags_from_this_input(i) ⇒ Object
(also: #remove_tags)
-
#rename_kde_konsole_tab(title = '.') ⇒ Object
# === rename_kde_konsole_tab ========================================================================= #.
-
#rename_konsole_tab?(i = FILE_RENAME_KONSOLE_TAB) ⇒ Boolean
# === rename_konsole_tab? ========================================================================= #.
-
#replace_all_html_colours_in_this(i, use_this_colour_for_the_default_colour = colour_for_questions? ) ⇒ Object
# === replace_all_html_colours_in_this.
-
#replace_bold_token_with_default_colour(i, use_this_colour = :mediumseagreen) ⇒ Object
# === replace_bold_token_with_default_colour.
-
#replace_italic_token_with_default_colour(i, colour_to_use = :royalblue) ⇒ Object
# === replace_italic_token_with_default_colour ========================================================================= #.
-
#replace_italic_token_with_this_colour(i, use_this_colour = :mediumseagreen) ⇒ Object
# === replace_italic_token_with_this_colour.
-
#replace_regular_numbers_with_unicode_numbers(i) ⇒ Object
# === replace_regular_numbers_with_unicode_numbers.
-
#replace_underline_token_with_default_colour(i, colour_to_use = :royalblue) ⇒ Object
# === replace_underline_token_with_default_colour ========================================================================= #.
-
#replace_underline_token_with_this_colour(i, use_this_colour = :royalblue) ⇒ Object
# === replace_underline_token_with_this_colour.
-
#require_open_uri ⇒ Object
# === require_open_uri ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#reset_the_internal_state ⇒ Object
# === reset_the_internal_state ========================================================================= #.
-
#return_all_bachelor_lectures(from_this_dataset = ::Studium.main_dataset?) ⇒ Object
# === return_all_bachelor_lectures.
-
#return_all_exams_on_this_day(i) ⇒ Object
# === return_all_exams_on_this_day ========================================================================= #.
-
#return_all_numbers_from(i) ⇒ Object
# === return_all_numbers_from.
-
#return_all_registered_curricula ⇒ Object
# === return_all_registered_curricula ========================================================================= #.
-
#return_all_steop_lectures ⇒ Object
# === return_all_steop_lectures ========================================================================= #.
-
#return_current_year ⇒ Object
(also: #current_year?)
# === return_current_year.
-
#return_dataset_for_this_topic(i) ⇒ Object
# === return_dataset_for_this_topic ========================================================================= #.
-
#return_dataset_from_this_curriculum_file(i) ⇒ Object
(also: #return_dataset_for_this_curriculum_file, #return_dataset_from_this_curriculum, #return_this_curriculum)
# === return_dataset_from_this_curriculum_file ========================================================================= #.
-
#return_dd_mm_yy_and_time_from(i) ⇒ Object
# === return_dd_mm_yy_and_time_from.
-
#return_directory_for(name_of_the_lecture, university) ⇒ Object
# === return_directory_for.
-
#return_ects_points_from_these_lectures(hash) ⇒ Object
# === return_ects_points_from_these_lectures.
-
#return_either_grey_or_the_custom_colour_for_answers ⇒ Object
# === return_either_grey_or_the_custom_colour_for_answers ========================================================================= #.
-
#return_either_grey_or_the_custom_colour_for_questions(custom_colours = ) ⇒ Object
# === return_either_grey_or_the_custom_colour_for_questions ========================================================================= #.
-
#return_file_for_this_curriculum(i = :bachelor_basisblock_biologie) ⇒ Object
(also: #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.
-
#return_german_name_for_this_english_month(i) ⇒ Object
(also: #to_german_month)
# === return_german_name_for_this_english_month ========================================================================= #.
-
#return_german_weekday_of?(i) ⇒ Boolean
# === return_german_weekday_of? ========================================================================= #.
-
#return_hh_mm_ss_from(i = Time.now) ⇒ Object
(also: #hh_mm_ss)
# === return_hh_mm_ss_from.
-
#return_hour_from_this(i) ⇒ Object
(also: #extract_the_time_from)
# === return_hour_from_this.
-
#return_lectures_from_bachelor_vektor_curriculum ⇒ Object
# === return_lectures_from_bachelor_vektor_curriculum ========================================================================= #.
-
#return_lectures_with_at_the_least_one_upcoming_exam ⇒ Object
# === return_lectures_with_at_the_least_one_upcoming_exam.
-
#return_local_path_of_this_pwdstud(i = 1) ⇒ Object
# === return_local_path_of_this_pwdstud ========================================================================= #.
-
#return_lva_number_of_this_lecture(this_lecture) ⇒ Object
# === return_lva_number_of_this_lecture ========================================================================= #.
-
#return_month_fitting_to_this_input(i) ⇒ Object
-
#return_n_days_until_monday(time_now = Time.now) ⇒ Object
# === return_n_days_until_monday ========================================================================= #.
-
#return_n_days_until_sunday(time_now = Time.now) ⇒ Object
# === return_n_days_until_sunday ========================================================================= #.
-
#return_n_exam_questions_in(this_topic) ⇒ Object
# === return_n_exam_questions_in.
-
#return_n_questions_were_answered_for_this_topic(i) ⇒ Object
# === return_n_questions_were_answered_for_this_topic ========================================================================= #.
-
#return_name_of_the_weekday(i = :today) ⇒ Object
(also: #return_weekday)
# === return_name_of_the_weekday.
-
#return_name_of_this_curriculum(i) ⇒ Object
(also: #return_long_name_of_this_curriculum)
# === return_name_of_this_curriculum.
-
#return_name_of_this_curriculum_based_on_its_id_number(i) ⇒ Object
(also: #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.
-
#return_opnn(use_this_namespace = NAMESPACE) ⇒ Object
(also: #ropnn)
# === return_opnn ========================================================================= #.
-
#return_passed_courses ⇒ Object
# === return_passed_courses.
-
#return_pwd ⇒ Object
(also: #pwd?)
# === return_pwd.
-
#return_random_curriculum ⇒ Object
# === return_random_curriculum ========================================================================= #.
-
#return_sanitized_dataset_from_the_file_lecture_information ⇒ Object
(also: #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_solved_lectures ⇒ Object
# === return_solved_lectures.
-
#return_steop_lectures(optional_ignore_already_completed_steop_lectures = true) ⇒ Object
# === return_steop_lectures (steop tag).
-
#return_the_remote_homepage_url(of_this_lecture, dataset_to_use) ⇒ Object
# === return_the_remote_homepage_url.
-
#return_this_line_has_n_characters_as_html_colour_tags(i) ⇒ Object
-
#return_title_from_this_curriculum_file(i, use_a_shorter_name = false) ⇒ Object
(also: #return_title_of, #return_pretty_title_of_this_curriculum, #return_title_of_this_curriculum)
# === return_title_from_this_curriculum_file.
-
#right_arrow? ⇒ Boolean
(also: #right_arrow, #rarrow, #rarrow?)
# === right_arrow? ========================================================================= #.
-
#rinstall2 ⇒ Object
(also: #r2)
# === rinstall2.
-
#roebe_exam_directory? ⇒ Boolean
# === roebe_exam_directory? ========================================================================= #.
-
#roebe_path_to_file_lecture_information? ⇒ Boolean
-
#ruby_src_dir_at_home? ⇒ Boolean
# === ruby_src_dir_at_home? ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#sanitize_this_topic(this_topic) ⇒ Object
# === sanitize_this_topic (sanitize tag, alias tag).
-
#sanitize_url(i, optional_extra_modes = nil) ⇒ Object
(also: #sanitized_url)
# === sanitize_url.
-
#select_for_prüfungsimmanente_LVs(i) ⇒ Object
# === select_for_prüfungsimmanente_LVs.
-
#select_lectures_with_this_key(searching_for_this_key) ⇒ Object
# === select_lectures_with_this_key.
-
#set_be_verbose ⇒ Object
(also: #be_verbose)
# === set_be_verbose ========================================================================= #.
-
#set_this_cd_alias_to(cd_alias, new_content, be_verbose = :default) ⇒ Object
# === set_this_cd_alias_to ========================================================================= #.
-
#set_xorg_buffer(i) ⇒ Object
# === set_xorg_buffer ========================================================================= #.
-
#sfancy(i = '', use_colours = use_colours? ) ⇒ Object
# === sfancy ========================================================================= #.
-
#shall_we_make_use_of_unicode_symbols? ⇒ Boolean
(also: #use_unicode_symbols?, #use_unicode?)
# === shall_we_make_use_of_unicode_symbols?.
-
#show_todays_date ⇒ Object
# === show_todays_date ========================================================================= #.
-
#silently_open_in_browser(into) ⇒ Object
# === silently_open_in_browser.
-
#simp(i = '', use_colours = use_colours? ) ⇒ Object
# === simp ========================================================================= #.
-
#sort_these_lecture_names_by_time(array, weekday) ⇒ Object
# === sort_these_lecture_names_by_time ========================================================================= #.
-
#spacer ⇒ Object
# === spacer ========================================================================= #.
-
#studium_log_dir? ⇒ Boolean
(also: #log_dir?, #base_dir?)
# === studium_log_dir?.
-
#this_month_has_n_days?(this_month, this_year = Time.now.year) ⇒ Boolean
# === this_month_has_n_days?.
-
#total_ects_points_passed(i) ⇒ Object
# === total_ects_points_passed ========================================================================= #.
-
#translate_dd_mm_yyyy_to_weekday(i = '25.02.2020') ⇒ Object
(also: #translate_dd_mm_yyy_to_weekday)
# === translate_dd_mm_yyyy_to_weekday.
-
#try_to_require_html_templates ⇒ Object
# === try_to_require_html_templates ========================================================================= #.
-
#try_to_require_the_open_gem ⇒ Object
# === try_to_require_the_open_gem ========================================================================= #.
-
#try_to_require_the_rcfiles ⇒ Object
# === try_to_require_the_rcfiles ========================================================================= #.
-
#try_to_require_the_verbose_truth_gem ⇒ Object
# === try_to_require_the_verbose_truth_gem ========================================================================= #.
-
#turn_this_array_into_the_full_dataset(i, use_this_dataset) ⇒ Object
# === turn_this_array_into_the_full_dataset.
-
#unicode_blocks_line(optional_use_this_colour = nil, use_n_tokens = :default, use_this_unicode_token = :upper_half_block) ⇒ Object
# === unicode_blocks_line.
-
#use_colours? ⇒ Boolean
# === use_colours? ========================================================================= #.
-
#use_opn? ⇒ Boolean
# === use_opn? ========================================================================= #.
-
#vertical_bar? ⇒ Boolean
# === vertical_bar? ========================================================================= #.
-
#web_liner(this_token = '*') ⇒ Object
# === web_liner ========================================================================= #.
-
#weekday?(i = Date.today.wday, use_this_language = :english) ⇒ Boolean
(also: #return_name_for_this_day, #return_weekday_for, #return_weekday_of, #return_weekday_from_this_input, #english_weekday, #english_weekday?)
# === weekday?.
-
#weekdays? ⇒ Boolean
# === weekdays?.
-
#word_wrap(text, line_width = N_CHARACTERS_PER_LINE) ⇒ Object
# === word_wrap.
-
#write_what_into(what, into, &block) ⇒ Object
(also: #store_what_into)
# === write_what_into.
-
#www_connection_is_unavailable ⇒ Object
(also: #www_is_unavailable)
# === www_connection_is_unavailable ========================================================================= #.
-
#yaml_dir? ⇒ Boolean
# === yaml_dir? ========================================================================= #.
-
#yellowrev(i) ⇒ Object
# === yellowrev ========================================================================= #.
-
#yes_or_no(i) ⇒ Object
# === yes_or_no ========================================================================= #.
#commandline?, #runmode?, #set_commandline_mode, #set_runmode, #set_www_mode, #www_mode?
#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
#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 = /^(.+)(\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 result << current_year end
result
end
|
#already_solved_this_lva_number?(i) ⇒ Boolean
#
already_solved_this_lva_number?
#
#append_what_into(what, into) ⇒ Object
#
append_what_into (append tag)
Use this method to save data into a specific file.
#
#available_topics_as_short_name ⇒ Object
Also known as:
available_topics?, exam_topics?, return_all_exam_topics, available_exam_topics?
#
available_topics_as_short_name
#
#average_grade(i = :default, round_to = 2) ⇒ Object
1199
1200
1201
1202
1203
1204
1205
|
# File 'lib/studium/base/base.rb', line 1199
def average_grade(
i = :default,
round_to = 2 )
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_silent ⇒ Object
Also known as:
be_quiet
761
762
763
|
# File 'lib/studium/base/base.rb', line 761
def be_silent
@internal_hash[:be_verbose] = false
end
|
#be_verbose? ⇒ 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?
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
881
882
883
884
885
|
# File 'lib/studium/base/base.rb', line 881
def change_directory(
i = Dir.pwd
)
FileUtils.chdir(i)
end
|
#cheering_person ⇒ Object
Also known as:
cheering_person?, cheering_dude?
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 if which_token_to_use.has_key? :colours
use_this_colour = which_token_to_use.delete(:colours)
which_token_to_use = :default_token
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
when :default_token
which_token_to_use = '='
end
if block_given?
yielded = yield
case yielded
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
#
#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? 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
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
when :winter
act_on_this_entry = :semester
when :prüfungsimmanent
act_on_this_entry = :type
end
return dataset.select {|name_of_the_course, inner_hash|
case act_on_this_entry
when :type
case filter_how
when :prüfungsimmanent
_ = inner_hash[act_on_this_entry]
is_prüfungsimmanent?(_)
else
false
end
when :semester
_ = inner_hash[act_on_this_entry]
if _
_.to_sym == filter_how else
e 'nil-entry for '+name_of_the_course+' - please fix this.'
end
when :university
inner_hash[act_on_this_entry].to_sym == filter_how
end
}
end
|
#cpruby ⇒ Object
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
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
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.
#
#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.
#
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).
#
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
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
if min_winter_day <= today.to_datetime and max_winter_day >= today.to_datetime
:winter
else
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.
#
3204
3205
3206
|
# File 'lib/studium/base/base.rb', line 3204
def dataset?
@internal_hash[:dataset]
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
2454
2455
2456
|
# File 'lib/studium/base/base.rb', line 2454
def debug?
@internal_hash[:debug]
end
|
#delete_file(i) ⇒ Object
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?
#directory_to_my_exam_topics ⇒ Object
#
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”.
#
#disable_colours ⇒ Object
Also known as:
no_colours
362
363
364
|
# File 'lib/studium/base/base.rb', line 362
def disable_colours
@internal_hash[:use_colours] = false
end
|
#disable_colours_globally ⇒ Object
#
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 end
|
#do_not_be_verbose ⇒ Object
Also known as:
set_be_quiet
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_opn ⇒ Object
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.
#
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?
#
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?
#
#does_this_line_include_an_english_weekday?(i) ⇒ Boolean
#
does_this_line_include_an_english_weekday?
#
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?
#
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
336
337
338
|
# File 'lib/studium/base/base.rb', line 336
def e(i = '')
puts i
end
|
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
|
# File 'lib/studium/base/base.rb', line 3444
def (
i = '',
use_colours = use_colours?
)
if use_colours
::Colours.(i)
else
e i
end
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
1632
1633
1634
|
# File 'lib/studium/base/base.rb', line 1632
def egrey(i)
e grey(i)
end
|
#enable_colours ⇒ Object
355
356
357
|
# File 'lib/studium/base/base.rb', line 355
def enable_colours
@internal_hash[:use_colours] = true
end
|
#enable_colours_globally ⇒ Object
#
enable_colours_globally
#
245
246
247
|
# File 'lib/studium/base/base.rb', line 245
def enable_colours_globally
::Studium.enable_colours
end
|
#enable_debug ⇒ Object
Also known as:
do_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.
#
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_exists ⇒ Object
#
ensure_that_the_log_directory_exists
This method will try to make sure that the log directory exists.
#
#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
|
#etomato(i) ⇒ Object
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
when :no_newline
make_newline = false
end
e(N) if make_newline
exit end
|
#
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 (i)
i =~ /(\d{1,2}\.\d{1,2}\.\d{4})/ 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?
#
#file_passed_exams_per_month ⇒ Object
Also known as:
passed_exams_per_month, local_csv_file?
#
file_passed_exams_per_month
#
#file_read_with_proper_encoding(this_file) ⇒ Object
#
file_read_with_proper_encoding
#
#filter_away_already_answered_questions(i) ⇒ Object
Also known as:
#
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.
#
#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.
#
#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”.
#
#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 = '-'
)
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
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.
#
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
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
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
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?
#
#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.
#
#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.
#
#has_lva_dates_registered?(i) ⇒ Boolean
Also known as:
has_any_lva_dates_registered?
#
has_lva_dates_registered?
#
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? 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?
#
#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.
#
2566
2567
2568
|
# File 'lib/studium/base/base.rb', line 2566
def has_year_entry?(this_line)
this_line =~ /\d{4}/ end
|
#hh_mm_ss_dd_mm_yyyy(i) ⇒ Object
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
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?
#infer_the_namespace ⇒ Object
#
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] = _ end
|
#initialize_the_internal_hash ⇒ Object
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 = {}
end
|
#internal_hash? ⇒ Boolean
Also known as:
ihash?
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_registered_curriculum?(i) ⇒ Boolean
#
is_a_registered_curriculum?
This calls code stored in the file /require ‘studium/toplevel_methods/toplevel_methods.rb’.
#
#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.
#
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?
#
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
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_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”.
#
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.
#
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’.
#
#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.
#
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?
#
#konsole_support? ⇒ Boolean
955
956
957
|
# File 'lib/studium/base/base.rb', line 955
def konsole_support?
true
end
|
#lectures_from_indi1 ⇒ Object
768
769
770
|
# File 'lib/studium/base/base.rb', line 768
def lectures_from_indi1
obtain_lectures_from_this_curriculum(:indi1)
end
|
#lectures_from_indi2 ⇒ Object
775
776
777
|
# File 'lib/studium/base/base.rb', line 775
def lectures_from_indi2
obtain_lectures_from_this_curriculum(:indi2)
end
|
#lectures_from_indi3 ⇒ Object
782
783
784
|
# File 'lib/studium/base/base.rb', line 782
def lectures_from_indi3
obtain_lectures_from_this_curriculum(:indi3)
end
|
#lectures_from_indi4 ⇒ Object
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_curriculum ⇒ Object
#
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_curricula ⇒ Object
#
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
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
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
|
#move_file(this_file, target) ⇒ Object
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 )
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! start_day = Date::DAYNAMES[weekday_as_number]
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
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
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
when :be_quiet
be_verbose = false
end
end
case be_verbose
when :be_quiet,
:be_silent
be_verbose = false
end
case this_key
when :passed_when,
:solved_at
this_key = :already_solved_at
when :passed_successfully
this_key = :already_solved
when :steop,
'steop'
this_key = :is_a_steop_lecture
when :curricula_entries,
:curricula,
'curricula'
this_key = 'curricula'
when :english_description
this_key = :description_in_english
when :german_description
this_key = :description_in_german
when :this_university,
:university
this_key = :university
when :n_ects, :n_ects_points
this_key = :ects
when :curricula_ids,
:curriculum_id
this_key = 'curricula'
when :lecturers
this_key = 'lecturers'
when 'homepage',
:remote_url
this_key = :homepage
when :semester, 'semester'
this_key = :semester
end
if this_key.is_a? Symbol
if hash.has_key? this_key
elsif hash.has_key? this_key.to_s
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] else
if be_verbose
case this_key
when :is_a_steop_lecture
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(' ') }
end
|
#open_in_browser(i) ⇒ Object
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
#opne(i) ⇒ Object
441
442
443
|
# File 'lib/studium/base/base.rb', line 441
def opne(i)
opnn; e i
end
|
#opnerev(i) ⇒ Object
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 i = { namespace: i }
end
Opn.opn(i, &block)
end
end
|
#padded_current_month?(i = current_month?
) ⇒ Boolean
#
padded_current_month?
#
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
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}/ 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?
#project_yaml_directory? ⇒ Boolean
#
project_yaml_directory?
#
3394
3395
3396
|
# File 'lib/studium/base/base.rb', line 3394
def project_yaml_directory?
Studium.project_yaml_directory?
end
|
#rds(i) ⇒ Object
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
#
#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
if File.exist? this_file
dataset = readlines_via_default_encoding(this_file) if block_given?
yielded = yield
case yielded
when :filter_away_the_comments
shall_we_filter_away_invalid_questions = true
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
|
#
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
when :default,
:default_encoding
use_this_encoding = ::Studium.main_encoding?
end
if use_this_encoding.is_a? Hash
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_sigint ⇒ Object
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
|
508
509
510
511
512
513
514
515
516
517
|
# File 'lib/studium/base/base.rb', line 508
def (i)
if i.is_a? Array
i.map {|line|
if line.include? '#'
line = line[0 .. (line.index('#') - 1)]
end
line.strip
}
end
end
|
1210
1211
1212
1213
1214
|
# File 'lib/studium/base/base.rb', line 1210
def (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.
#
#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
|
#
This method will return all HTML-like tags from the given input String.
#
#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
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?
)
::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?>/ 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 ¹.
#
#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 )
if (i.include?('<ud>') and i.include?('</ud>')) or
(i.include?('<u>') and i.include?('</u>'))
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_uri ⇒ Object
3166
3167
3168
|
# File 'lib/studium/base/base.rb', line 3166
def require_open_uri
require 'open-uri'
end
|
#reset ⇒ Object
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 @internal_hash[:namespace] = NAMESPACE
@internal_hash[:use_colours] = ::Studium.use_colours?
@internal_hash[:be_verbose] = true
@internal_hash[:use_opn] = true
@internal_hash[:debug] = false
if Studium.runmode?
set_runmode(Studium.runmode?)
else
set_runmode(:commandline) end
end
|
#reset_the_internal_state ⇒ Object
#
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] = 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
#
#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+/ }
end
return_this
end
|
#return_all_registered_curricula ⇒ Object
#
return_all_registered_curricula
#
#return_all_steop_lectures ⇒ Object
#
return_all_steop_lectures
#
#return_current_year ⇒ Object
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
#
#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.
#
#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.
#
#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 hash.each_pair {|lecture_id, 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_answers ⇒ Object
#
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
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?
#
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:
#
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_curriculum ⇒ Object
#
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_exam ⇒ Object
#
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
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 else
false
end
}
end
|
#return_local_path_of_this_pwdstud(i = 1) ⇒ Object
#
return_local_path_of_this_pwdstud
#
#return_lva_number_of_this_lecture(this_lecture) ⇒ Object
#
return_lva_number_of_this_lecture
#
#
This method will return a number.
#
#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.
#
#return_n_questions_were_answered_for_this_topic(i) ⇒ Object
#
return_n_questions_were_answered_for_this_topic
#
#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
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’.
#
#return_opnn(use_this_namespace = NAMESPACE) ⇒ Object
Also known as:
ropnn
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_courses ⇒ Object
#
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_pwd ⇒ Object
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_curriculum ⇒ Object
#
return_random_curriculum
#
#
This method will return the dataset stored in the file ‘lecture_information.yml’.
#
#return_solved_lectures ⇒ Object
#
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_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)
#
#right_arrow? ⇒ Boolean
Also known as:
right_arrow, rarrow, rarrow?
1804
1805
1806
|
# File 'lib/studium/base/base.rb', line 1804
def right_arrow?
UNICODE_RIGHT_ARROW
end
|
#rinstall2 ⇒ Object
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?
#
1625
1626
1627
|
# File 'lib/studium/base/base.rb', line 1625
def roebe_exam_directory?
"#{RUBY_STUDIUM_HOME_DIR}exam_topics/"
end
|
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?
#
#run ⇒ Object
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.
#
#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.
#
#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 return dataset
end
|
#set_be_verbose ⇒ Object
Also known as:
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_xorg_buffer(i) ⇒ Object
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
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?
#
#show_todays_date ⇒ Object
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
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 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) if lva_date.include? '-'
lva_date = lva_date.split('-').first
end
timestamp = Time.parse(lva_date)
timestamp }
end
|
#studium_log_dir? ⇒ Boolean
Also known as:
log_dir?, base_dir?
#
studium_log_dir?
This is the log dir - where we “operate on”.
#
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.
#
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
#
#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_templates ⇒ Object
#
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_gem ⇒ Object
#
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_rcfiles ⇒ Object
#
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_gem ⇒ Object
#
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, use_this_unicode_token = :upper_half_block
)
case use_n_tokens
when :default 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
369
370
371
|
# File 'lib/studium/base/base.rb', line 369
def use_colours?
@internal_hash[:use_colours]
end
|
#use_opn? ⇒ Boolean
1429
1430
1431
|
# File 'lib/studium/base/base.rb', line 1429
def use_opn?
@internal_hash[:use_opn]
end
|
#vertical_bar? ⇒ Boolean
1684
1685
1686
|
# File 'lib/studium/base/base.rb', line 1684
def vertical_bar?
return '|'
end
|
#web_liner(this_token = '*') ⇒ Object
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.
#
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?('.')
begin
i = Time.parse(i).wday
rescue ArgumentError => error
pp error
end
end
result = Date::DAYNAMES[i]
case use_this_language
when :german,
:use_german
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.
#
#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.
#
#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_unavailable ⇒ Object
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
276
277
278
|
# File 'lib/studium/base/base.rb', line 276
def yaml_dir?
Studium.yaml_directory?
end
|
#yellowrev(i) ⇒ Object
216
217
218
|
# File 'lib/studium/base/base.rb', line 216
def yellowrev(i)
"#{yellow(i)}#{rev}"
end
|
#yes_or_no(i) ⇒ Object
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
|