Class: Studium::Base
- Inherits:
-
Object
show all
- Includes:
- Colours
- Defined in:
- lib/studium/base/run.rb,
lib/studium/base/misc.rb,
lib/studium/base/mode.rb,
lib/studium/base/opnn.rb,
lib/studium/base/time.rb,
lib/studium/base/reset.rb,
lib/studium/base/cliner.rb,
lib/studium/base/editor.rb,
lib/studium/base/obtain.rb,
lib/studium/base/colours.rb,
lib/studium/base/esystem.rb,
lib/studium/base/replace.rb,
lib/studium/base/unicode.rb,
lib/studium/base/encoding.rb,
lib/studium/base/constants.rb,
lib/studium/base/prototype.rb,
lib/studium/base/readlines.rb,
lib/studium/base/word_wrap.rb,
lib/studium/base/curriculum.rb,
lib/studium/base/src_dir_at_home.rb,
lib/studium/base/minimal_prototype.rb,
lib/studium/base/commandline_arguments.rb,
lib/studium/base/directory_to_the_exam_topics.rb
Overview
Direct Known Subclasses
Afterburn, AskQuestionFromAlias, AskQuestionFromGroupedThemes, AskQuestionFromLastTopic, AskRandomQuestion, AttributeLecturesToUniversity, AudioStats, AutoStud, AutopurgeThisLectureDate, Studium::BOKU::ShowThreePillarsOfTheseLectures, Studium::BOKU::ThreePillars, BokuBiotechnologyAllMasterLectures, BokuEctsSplitter, Calendar, CheckCurriculumForCorrectSeparationOfBachelorAndMaster, CheckDescriptionOfTheseLectures, CheckForAllExamTopicsBeingRegistered, CheckTheLectureInformationFile, CleanUpLectureDate, Commandline, CreateDatabase, CreatePdfFileForThisExamTopic, CurrentLecturesBelongingToBothBachelorAndMasterCurriculum, CurrentlyParticipatingInTheseLectures, Curricula::CurriculumAsString, Curricula::DetermineElectiveCoursesInThisCurriculum, Curricula::DisplayBachelorCurricula, Curricula::Mitteilungsblätter, Curricula::Modules::DisplayOnTheCommandline, Curriculum, CurriculumComparer, CurriculumModuleDisplayer, DetermineCurricula, DisplayLectureUrl, EctsParser, EctsPerUniversity, EctsScanner, EctsToUniversityParser, Erledigt, Exams::AskExamFromTheUpcomingExamsPool, Exams::AskExamTopicQuestion, Exams::AskQuestionFromAnyOfTheStillMissingLectures, Exams::CreateCsvPassedExamsFile, Exams::Cycle, Exams::DesignateTenRandomExamTopics, Exams::Exam, Exams::ExamQuestion, Exams::ExamRegistrationAt, Exams::ExamStatisticsFromThisFile, Exams::ExamTopics, Exams::LastExams, Exams::LecturesWithoutExamEntry, Exams::MandatoryContinuousAssessment, Exams::NewQuestionsPerYear, Exams::NextExam, Exams::NextExams, Exams::OpenExamAssociatedUrl, Exams::OpenLastExamQuestionAskedFile, Exams::Pruefung, Exams::PublishMyExams, Exams::PushSolvedQuestionsOnTop, Exams::QuestionsSolvedFromDayToDay, Exams::RepeatLastQuestion, Exams::ShowThemes, Exams::Solved, Exams::UpcomingExams, Exams::UpcomingExamsAtTheBoku, Exams::UpcomingExamsDataset, Exams::UploadExamTopics, ExamsPerMonth, ExamsThisWeek, ExpandTimeRange, FindDuplicateLectures, FinishedExamsAtThisUniversity, FixExamDates, ForeignLanguagePercentage, GenerateRegex, GenerateSpreadsheet, Holidays, IndividualResolvePracticalCoursesDateConflicts, LastEntryIsCurriculum, LectureDownloader, LecturesAttributedToUniversities, Log::StoreLastQuestionAskedIntoFile, LvaNummer, MandatoryLecturesInThisMonth, MoveTheLastExamQuestionToTheTopOfTheFile, NEctsInTheseLectures, NExamsInTheseTopics, NameOfThisLvaId, NewStud, NextWeek, NochZuAbsolvieren, OpenLastExamQuestionUrlLinkViaTheBrowser, ParseLvaDates, PassedEctsPerYear, PassedPrüfungsimmanenteCourses, PrepareIndividualCurriculum, Priority, PriorityPoints, RandomCurriculumCreator, ReportOutdatedTimetableEntries, ReportTotalAmountOfQuestionsAndAnswersFor, ReportWhetherThisLectureIsRegisteredInTheFileLectureInformation, ResolvePracticalCoursesDateConflicts, ReturnNEctsFromThisUrl, SanitizeThisStringContainingTheLvaDates, ScrapeRemoteUniversityUrl, SearchFor_nECTS, SemesterContainer, Semesterplaner, SetAliasesBasedOnThisFile, ShowAllLectures, ShowAllPassedExamsOfThisUniversity, ShowAllPassedMasterLectures, ShowAllSteopLectures, ShowBacklogOfExams, ShowCompletedEctsInAllCurricula, ShowConflictingLvaLectures, ShowDescriptionsOfLecturesBelongingToThisModule, ShowLecturers, ShowLectures, ShowLecturesFittingToThisLanguage, ShowLecturesFittingToThisTheme, ShowLecturesOfThisCurriculum, ShowLecturesOfThisCurriculumId, ShowLecturesOnTheCommandline, ShowLecturesOnThisDay, ShowLvaDatesOfThisLecture, ShowNextExamsFor, ShowOutdatedLvaDates, ShowPassedCreditsPerCurriculum, ShowSolvedEnglishLectures, ShowSolvedPercentageAmongTheRegisteredCurricula, ShowTheAssociatedLecturesForTheIndividualCurriculum, ShowUpcomingExams, SimpleTotalEctsPoints, SolveAllQuestionsFromThisTopic, SolvedEcts, SolvedEctsPerUniversity, SortedIndividualCurricula, Statistics::BestExamMonths, Statistics::DetermineExamStatisticsFromThisFile, Statistics::MaxStats, Statistics::ReportHowManyEctsPointsPerCurriculumWereCompleted, Statistics::ReportHowManyExamQuestionsWereAnswered, Statistics::TopStats, SteopLecturesInThisCurriculum, SteopLvaDates, StillMissing, Studienkennzahl, StudiumSkeleton, Stundenplan, SumOfEcts, SyncStudiumRelevantEntriesOneLevelDownwards, Ufind, UnsolveAllQuestionsFromThisTopic, UpcomingMandatoryPresenceCourses, Vorbesprechungen, WeekParser, WeekdayParser, WeeklySchedule, Wochenplanung
Constant Summary
collapse
- COMMON_YEAR_DAYS_IN_MONTH =
#
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
]
- GRAY =
::Colours::GRAY
- COLOURS =
#
COLOURS
This could go into studium/base/constants.rb, but it seems to fit better here as a “pointer” towards colours.
#
::Colours::AllColourMethods
- ARRAY_HTML_COLOURS_IN_USE =
#
ARRAY_HTML_COLOURS_IN_USE
Next, we will define the html-colours.
#
%w(
aquamarine
chocolate
cadetblue
coral
cornflowerblue
crimson
cyan
darkblue
darkgoldenrod
darkred
darkgreen
darkkhaki
darkolivegreen
darkorange
darkseagreen
darkslateblue
darkslategray
darkturquoise
mediumseagreen
forestgreen
brown
silver
deepskyblue
firebrick
gold
goldenrod
indianred
khaki
lavender
lawngreen
lightcoral
lightgreen
lightseagreen
lightslategrey
lightred
lightskyblue
lime
mediumpurple
mediumspringgreen
mediumvioletred
mediumturquoise
mediumslateblue
mintcream
orange
orchid
palegoldenrod
peru
lightslategray
seagreen
saddlebrown
sandybrown
steelblue
teal
turquoise
skyblue
tomato
oldlace
olivedrab
mediumblue
lightblue
limegreen
orangered
palegreen
plum
powderblue
slateblue
salmon
red
sienna
tan
yellow
palevioletred
thistle
slategray
mediumaquamarine
darkcyan
springgreen
violet
whitesmoke
olive
paleturquoise
rosybrown
royalblue
yellowgreen
)
- UNICODE_RIGHT_ARROW =
'→'
- NAMESPACE =
inspect
true
- LEFT_PADDING =
#
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
- N_CHARACTERS_PER_LINE =
#
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
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?, #return_all_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.
-
#base_dir? ⇒ Boolean
(also: #log_dir?)
# === base_dir?.
-
#be_silent ⇒ Object
(also: #be_quiet)
# === be_silent ========================================================================= #.
-
#be_verbose? ⇒ Boolean
# === be_verbose? ========================================================================= #.
-
#beautiful_url(i) ⇒ Object
# === beautiful_url.
-
#change_directory(i = Dir.pwd) ⇒ Object
(also: #cd)
# === change_directory ========================================================================= #.
-
#cheering_person ⇒ Object
(also: #cheering_person?, #cheering_dude?)
# === cheering_person ========================================================================= #.
-
#cliner(which_token_to_use = :default_token, use_this_colour = nil) ⇒ 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.
-
#commandline_arguments? ⇒ Boolean
(also: #commandline?)
# === commandline_arguments? ========================================================================= #.
-
#commandline_arguments_joined ⇒ Object
(also: #return_commandline_arguments_as_string, #commandline_arguments_as_string, #commandline_arguments_as_string?, #commandline_string?, #commandline_as_string, #return_original_input_as_string)
# === commandline_arguments_joined.
-
#commandline_arguments_with_hyphens? ⇒ Boolean
(also: #return_commandline_arguments_with_leading_hyphens, #return_hyphened_commandline_arguments)
# === commandline_arguments_with_hyphens?.
-
#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) ========================================================================= #.
-
#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?.
-
#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)
# === 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
# === 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
# === does_this_line_include_a_german_weekday? ========================================================================= #.
-
#does_this_line_include_a_html_colour?(i) ⇒ Boolean
# === does_this_line_include_a_html_colour? ========================================================================= #.
-
#e(i = '') ⇒ Object
# === e (e tag) ========================================================================= #.
-
#ecomment(i = '') ⇒ Object
-
#editor? ⇒ Boolean
# === editor? ========================================================================= #.
-
#ee(i = '') ⇒ Object
# === ee (ee tag).
-
#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
# === english_to_german_weekday.
-
#ensure_main_encoding(i) ⇒ Object
(also: #use_correct_encoding, #sanitize_encoding)
# === ensure_main_encoding.
-
#ensure_that_the_log_directory_exists ⇒ Object
# === ensure_that_the_log_directory_exists.
-
#eparse(i) ⇒ Object
# === eparse.
-
#erev(i) ⇒ Object
# === erev ========================================================================= #.
-
#esystem(i) ⇒ Object
# === esystem ========================================================================= #.
-
#etomato(i) ⇒ Object
# === etomato ========================================================================= #.
-
#exit_program(make_newline = :no_newline) ⇒ Object
# === exit_program (exit tag).
-
#expand_topic(i) ⇒ Object
(also: #find_corresponding_exam_title)
# === expand_topic.
-
#extract_dd_mm_yyyy(i) ⇒ Object
(also: #extract_ddmmyyyy)
-
#file_lecture_information? ⇒ Boolean
-
#file_read_with_proper_encoding(this_file) ⇒ Object
# === file_read_with_proper_encoding ========================================================================= #.
-
#filter_away_invalid_questions(i) ⇒ Object
# === filter_away_invalid_questions.
-
#find_corresponding_exam_topic(i) ⇒ Object
(also: #return_file_associated_with_this_exam_topic)
# === find_corresponding_exam_topic.
-
#first_argument? ⇒ Boolean
(also: #first?)
# === first_argument?.
-
#first_non_hyphen_argument? ⇒ Boolean
# === first_non_hyphen_argument? ========================================================================= #.
-
#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? ========================================================================= #.
-
#has_a_bachelor_curriculum?(array) ⇒ Boolean
(also: #is_a_bachelor_lecture?, #has_a_bachelor_curriculum_entry?, #is_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?)
# === has_a_master_curriculum?.
-
#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? ========================================================================= #.
-
#is_a_master_lecture?(i) ⇒ Boolean
# === is_a_master_lecture? ========================================================================= #.
-
#is_a_weekday?(i = 'Montag') ⇒ Boolean
# === is_a_weekday?.
-
#is_connected_to_the_www? ⇒ Boolean
# === is_connected_to_the_www? ========================================================================= #.
-
#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_prüfungsimmanent?.
-
#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?.
-
#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.
-
#load_yaml_dataset(i, do_rescue = false) ⇒ Object
# === load_yaml_dataset.
-
#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.
-
#no_ext_name(i) ⇒ Object
# === no_ext_name.
-
#no_file_at(i) ⇒ Object
(also: #no_file_exists_at)
# === no_file_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_lectures_from_this_curriculum.
-
#open_in_editor(i) ⇒ Object
# === open_in_editor ========================================================================= #.
-
#opnn(i = @namespace, &block) ⇒ Object
# === opnn.
-
#path_to_exam_topic? ⇒ Boolean
# === directory_to_the_exam_topics? ========================================================================= # === path_to_exam_topic?.
-
#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) ⇒ Object
# === 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) ⇒ Object
(also: #readlines_via_default_encoding, #readlines_with_default_encoding, #readlines_with_the_default_encoding, #readlines_with_iso_encoding, #file_readlines_of_this_file, #file_readlines, #readlines_with_proper_encoding, #proper_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_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.
-
#reset ⇒ Object
# === reset (reset tag).
-
#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 ⇒ 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_file_associated_with_this_curriculum, #location_of_this_curriculum_file?)
# === return_file_for_this_curriculum ========================================================================= #.
-
#return_german_name_for_this_english_month(i) ⇒ Object
# === return_german_name_for_this_english_month ========================================================================= #.
-
#return_german_weekday_of?(i) ⇒ Boolean
# === return_german_weekday_of? ========================================================================= #.
-
#return_hh_mm_ss_from(i) ⇒ 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
require 'studium/toplevel_methods/return_n_questions_were_answered_for_this_topic.rb' ^^^ this is already required elsewhere.
-
#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, #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_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_title_from_this_curriculum_file.
-
#rev ⇒ Object
(also: #revert)
# === rev (rev tag) ========================================================================= #.
-
#right_arrow? ⇒ Boolean
# === right_arrow? ========================================================================= #.
-
#rinstall2 ⇒ Object
# === rinstall2 ========================================================================= #.
-
#roebe_exam_directory? ⇒ Boolean
# === roebe_exam_directory? ========================================================================= #.
-
#ruby_src_dir_at_home? ⇒ Boolean
# === ruby_src_dir_at_home? ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#runmode? ⇒ Boolean
(also: #mode?)
# === runmode? ========================================================================= #.
-
#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_lectures_with_this_key(searching_for_this_key) ⇒ Object
# === select_lectures_with_this_key.
-
#set_be_quiet ⇒ Object
# === set_be_quiet ========================================================================= #.
-
#set_be_verbose ⇒ Object
(also: #be_verbose)
# === set_be_verbose ========================================================================= #.
-
#set_commandline_arguments(i = ARGV) ⇒ Object
# === set_commandline_arguments.
-
#set_commandline_mode ⇒ Object
(also: #set_commandline)
# === set_commandline_mode ========================================================================= #.
-
#set_runmode(i = ::Studium::Exams.runmode?) ⇒ Object
(also: #set_mode)
# === set_runmode.
-
#set_this_cd_alias_to(cd_alias, new_content, be_verbose = :default) ⇒ Object
# === set_this_cd_alias_to ========================================================================= #.
-
#set_www_mode ⇒ Object
(also: #www_mode)
# === set_www_mode.
-
#sfancy(i = '') ⇒ 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 ========================================================================= #.
-
#simp(i = '') ⇒ Object
# === simp ========================================================================= #.
-
#sort_these_lecture_names_by_time(array, weekday) ⇒ Object
# === sort_these_lecture_names_by_time ========================================================================= #.
-
#spacer ⇒ Object
# === spacer ========================================================================= #.
-
#swarn(i = '') ⇒ Object
# === swarn ========================================================================= #.
-
#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_the_rcfiles ⇒ Object
# === try_to_require_the_rcfiles ========================================================================= #.
-
#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) ⇒ Object
(also: #store_what_into)
# === write_what_into.
-
#www_connection_is_unavailable ⇒ Object
(also: #www_is_unavailable)
# === www_connection_is_unavailable ========================================================================= #.
-
#www_mode? ⇒ Boolean
(also: #is_on_www?, #are_we_in_www_mode?, #in_www_mode?)
# === www_mode?.
-
#yaml_dir? ⇒ Boolean
# === yaml_dir? ========================================================================= #.
Methods included from Colours
#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, sfile, #sfile, simp, slateblue, steelblue, #steelblue, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow
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"
#
235
236
237
238
239
240
241
242
243
244
245
246
|
# File 'lib/studium/base/time.rb', line 235
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?, return_all_exam_topics
#
available_topics_as_short_name
#
#average_grade(i = :default, round_to = 2) ⇒ Object
#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.
#
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/studium/base/curriculum.rb', line 97
def bachelor_master_or_diploma(
this_lecture, dataset = nil
)
if dataset.nil? and File.exist? FILE_PASSED_EXAMS_PER_MONTH
dataset = File.readlines(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
|
#base_dir? ⇒ Boolean
Also known as:
log_dir?
#
base_dir?
This is the log dir - where we “operate on”.
#
665
666
667
|
# File 'lib/studium/base/misc.rb', line 665
def base_dir?
Studium.log_dir?
end
|
#be_silent ⇒ Object
Also known as:
be_quiet
209
210
211
|
# File 'lib/studium/base/misc.rb', line 209
def be_silent
@be_verbose = false
end
|
#be_verbose? ⇒ Boolean
805
806
807
|
# File 'lib/studium/base/misc.rb', line 805
def be_verbose?
@be_verbose
end
|
#beautiful_url(i) ⇒ Object
#
beautiful_url
Until 10.12.2019 this exclusively used BeautifulUrl.
Since as of 10.12.2019, this method will actually tap into Studium.return_url_from if it is registered.
#
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/studium/base/misc.rb', line 45
def beautiful_url(i)
unless Studium.respond_to? :is_this_url_registered?
require 'studium/utility_scripts/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
445
446
447
448
449
|
# File 'lib/studium/base/misc.rb', line 445
def change_directory(
i = Dir.pwd
)
FileUtils.chdir(i)
end
|
#cheering_person ⇒ Object
Also known as:
cheering_person?, cheering_dude?
573
574
575
|
# File 'lib/studium/base/misc.rb', line 573
def cheering_person
'\o/'
end
|
#cliner(which_token_to_use = :default_token, use_this_colour = nil) ⇒ Object
#
cliner (cliner tag)
This method can be used such as in the following example, if a specific colour is wanted:
cliner('*', :mediumaquamarine)
#
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/studium/base/cliner.rb', line 20
def cliner(
which_token_to_use = :default_token,
use_this_colour = nil
)
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
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
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)
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.
#
212
213
214
215
|
# File 'lib/studium/base/colours.rb', line 212
def colourize_percentage(i)
return seagreen(i) if use_colours? return i
end
|
#commandline_arguments? ⇒ Boolean
Also known as:
commandline?
#
commandline_arguments?
#
26
27
28
|
# File 'lib/studium/base/commandline_arguments.rb', line 26
def commandline_arguments?
@commandline_arguments
end
|
#commandline_arguments_joined ⇒ Object
Also known as:
return_commandline_arguments_as_string, commandline_arguments_as_string, commandline_arguments_as_string?, commandline_string?, commandline_as_string, return_original_input_as_string
#
commandline_arguments_joined
This method will, essentially, return all commandline-arguments as a String.
#
46
47
48
|
# File 'lib/studium/base/commandline_arguments.rb', line 46
def commandline_arguments_joined
@commandline_arguments.join(' ').strip
end
|
#commandline_arguments_with_hyphens? ⇒ Boolean
Also known as:
return_commandline_arguments_with_leading_hyphens, return_hyphened_commandline_arguments
#
commandline_arguments_with_hyphens?
This method will select all the commandline arguments that begin with '–' hyphens.
#
61
62
63
64
65
|
# File 'lib/studium/base/commandline_arguments.rb', line 61
def commandline_arguments_with_hyphens?
@commandline_arguments.select {|entry|
entry.start_with?('--')
}
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.
#
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/studium/base/curriculum.rb', line 66
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
908
909
910
911
912
913
914
915
916
|
# File 'lib/studium/base/misc.rb', line 908
def copy(from, to)
if from.is_a? Array
from.each {|entry|
copy(entry, to)
}
else
FileUtils.copy(from, to)
end
end
|
#cpruby ⇒ Object
840
841
842
843
844
845
846
|
# File 'lib/studium/base/misc.rb', line 840
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
438
439
440
|
# File 'lib/studium/base/misc.rb', line 438
def create_directory(i)
FileUtils.mkdir_p(i)
end
|
#create_file(i) ⇒ Object
Also known as:
touch
379
380
381
|
# File 'lib/studium/base/misc.rb', line 379
def create_file(i)
FileUtils.touch(i)
end
|
#current_month? ⇒ Boolean
Also known as:
month?, return_current_month_as_a_number
#
current_month?
Show us the current month, as Integer. For example, for April, this method would return the number 4.
#
549
550
551
|
# File 'lib/studium/base/time.rb', line 549
def current_month?
Time.now.strftime('%m').to_i
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
#
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
#
370
371
372
373
374
375
376
377
378
|
# File 'lib/studium/base/time.rb', line 370
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
202
203
204
|
# File 'lib/studium/base/misc.rb', line 202
def debug?
@debug
end
|
#delete_file(i) ⇒ Object
864
865
866
|
# File 'lib/studium/base/misc.rb', line 864
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
#
#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
190
191
192
|
# File 'lib/studium/base/colours.rb', line 190
def disable_colours
@use_colours = false
end
|
#disable_colours_globally ⇒ Object
#
disable_colours_globally
Disable the colours globally, that is, on a per-project basis.
#
153
154
155
|
# File 'lib/studium/base/colours.rb', line 153
def disable_colours_globally
::Studium.disable_colours end
|
#do_not_be_verbose ⇒ Object
234
235
236
|
# File 'lib/studium/base/misc.rb', line 234
def do_not_be_verbose
@be_verbose = false
end
|
#do_not_use_opn ⇒ Object
42
43
44
|
# File 'lib/studium/base/opnn.rb', line 42
def do_not_use_opn
@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.
#
219
220
221
222
223
224
225
226
|
# File 'lib/studium/base/curriculum.rb', line 219
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
#
does_this_line_include_a_german_weekday?
#
437
438
439
440
441
|
# File 'lib/studium/base/time.rb', line 437
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?
#
#e(i = '') ⇒ Object
26
27
28
|
# File 'lib/studium/base/minimal_prototype.rb', line 26
def e(i = '')
puts i
end
|
160
161
162
|
# File 'lib/studium/base/colours.rb', line 160
def (i = '')
::Colours.(i)
end
|
#ee(i = '') ⇒ Object
#
ee (ee tag)
This is just a wrapper over print, essentially.
#
35
36
37
|
# File 'lib/studium/base/minimal_prototype.rb', line 35
def ee(i = '')
print i
end
|
#enable_colours ⇒ Object
183
184
185
|
# File 'lib/studium/base/colours.rb', line 183
def enable_colours
@use_colours = true
end
|
#enable_colours_globally ⇒ Object
#
enable_colours_globally
#
144
145
146
|
# File 'lib/studium/base/colours.rb', line 144
def enable_colours_globally
::Studium.enable_colours
end
|
#enable_debug ⇒ Object
Also known as:
do_debug
195
196
197
|
# File 'lib/studium/base/misc.rb', line 195
def enable_debug
@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.
#
19
20
21
|
# File 'lib/studium/base/encoding.rb', line 19
def encoding?
::Studium.main_encoding?
end
|
#english_to_german_weekday(english_day) ⇒ Object
#
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.
#
410
411
412
|
# File 'lib/studium/base/time.rb', line 410
def english_to_german_weekday(english_day)
ENGLISH_TO_GERMAN_WEEKDAYS[english_day]
end
|
#ensure_main_encoding(i) ⇒ Object
Also known as:
use_correct_encoding, sanitize_encoding
#
ensure_main_encoding
This method will ensure that we will have the right encoding set.
#
#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) ⇒ Object
#
eparse
The colours for this method are defined within the method body.
We could also delegate to ::Colours.eparse() instead.
#
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/studium/base/colours.rb', line 265
def eparse(i)
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
|
#erev(i) ⇒ Object
310
311
312
|
# File 'lib/studium/base/colours.rb', line 310
def erev(i)
e "#{rev}#{i}"
end
|
#esystem(i) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/studium/base/esystem.rb', line 15
def esystem(i)
if i.is_a? Array
i.each {|entry| esystem(entry) }
else
Studium.esystem(i)
end
end
|
#etomato(i) ⇒ Object
243
244
245
|
# File 'lib/studium/base/colours.rb', line 243
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
#
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/studium/base/minimal_prototype.rb', line 53
def exit_program(
make_newline = :no_newline
)
case make_newline
when :no_newline
make_newline = false
end
e(N) if make_newline
exit end
|
#expand_topic(i) ⇒ Object
Also known as:
find_corresponding_exam_title
#
expand_topic
This will expand e. g. 'allgemeine_genetik' to 'Allgemeine Genetik'.
#
#
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”.
#
205
206
207
208
|
# File 'lib/studium/base/time.rb', line 205
def (i)
i =~ /(\d{1,2}\.\d{1,2}\.\d{4})/ $1.to_s.dup
end
|
#file_read_with_proper_encoding(this_file) ⇒ Object
#
file_read_with_proper_encoding
#
#filter_away_invalid_questions(i) ⇒ Object
#
filter_away_invalid_questions
This method will remove entries that begin with '#' and empty entries.
#
#find_corresponding_exam_topic(i) ⇒ Object
Also known as:
return_file_associated_with_this_exam_topic
#
find_corresponding_exam_topic
This method will find the corresponding exam topic, based on a short input. For example, “bem1” will be short for basic biochemistry.
#
#first_argument? ⇒ Boolean
Also known as:
first?
#
first_argument?
This method will attempt to return the first commandline argument given.
#
36
37
38
|
# File 'lib/studium/base/commandline_arguments.rb', line 36
def first_argument?
@commandline_arguments and @commandline_arguments.first
end
|
#first_non_hyphen_argument? ⇒ Boolean
#
first_non_hyphen_argument?
#
71
72
73
74
75
|
# File 'lib/studium/base/commandline_arguments.rb', line 71
def first_non_hyphen_argument?
@commandline_arguments.select {|entry|
!entry.start_with?('--')
}.first
end
|
#from_curriculum_id_to_university(id) ⇒ Object
Also known as:
from_curriculum_number_to_university, which_university?
#
from_curriculum_id_to_university
This method will translate from the curriculum-ID to the university. So it will return a String such as “BOKU”.
#
#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.
#
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
# File 'lib/studium/base/time.rb', line 317
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.
#
560
561
562
563
564
|
# File 'lib/studium/base/time.rb', line 560
def german_weekday?(
i = Date.today.wday
)
weekday?(i, :german)
end
|
#german_weekdays? ⇒ Boolean
#has_a_bachelor_curriculum?(array) ⇒ Boolean
Also known as:
is_a_bachelor_lecture?, has_a_bachelor_curriculum_entry?, is_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?
#
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_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.
#
218
219
220
|
# File 'lib/studium/base/time.rb', line 218
def has_year_entry?(this_line)
this_line =~ /\d{4}/ end
|
#hh_mm_ss_dd_mm_yyyy(i) ⇒ Object
493
494
495
|
# File 'lib/studium/base/time.rb', line 493
def hh_mm_ss_dd_mm_yyyy(i)
hh_mm_ss(i)+'-'+dd_mm_yyyy(i)
end
|
#horizontal_bar? ⇒ Boolean
84
85
86
|
# File 'lib/studium/base/unicode.rb', line 84
def horizontal_bar?
return '―'
end
|
#html_log_directory? ⇒ Boolean
Also known as:
html_log_dir?
#is_a_master_lecture?(i) ⇒ Boolean
#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.
#
221
222
223
224
225
226
227
228
229
|
# File 'lib/studium/base/misc.rb', line 221
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?
#
639
640
641
|
# File 'lib/studium/base/misc.rb', line 639
def is_connected_to_the_www?
!@no_connection_to_the_www
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_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”.
#
714
715
716
717
718
|
# File 'lib/studium/base/misc.rb', line 714
def is_prüfungsimmanent?(
i, ignore_these_types = nil
)
Studium.is_prüfungsimmanent?(i, ignore_these_types)
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.
#
391
392
393
|
# File 'lib/studium/base/time.rb', line 391
def is_this_day_today?(i = '18.02.2022')
dd_mm_yyyy(Time.now) == dd_mm_yyyy(i)
end
|
#konsole_support? ⇒ Boolean
519
520
521
|
# File 'lib/studium/base/misc.rb', line 519
def konsole_support?
true
end
|
#lectures_from_indi1 ⇒ Object
301
302
303
|
# File 'lib/studium/base/curriculum.rb', line 301
def lectures_from_indi1
obtain_lectures_from_this_curriculum(:indi1)
end
|
#lectures_from_indi2 ⇒ Object
308
309
310
|
# File 'lib/studium/base/curriculum.rb', line 308
def lectures_from_indi2
obtain_lectures_from_this_curriculum(:indi2)
end
|
#lectures_from_indi3 ⇒ Object
315
316
317
|
# File 'lib/studium/base/curriculum.rb', line 315
def lectures_from_indi3
obtain_lectures_from_this_curriculum(:indi3)
end
|
#lectures_from_indi4 ⇒ Object
322
323
324
|
# File 'lib/studium/base/curriculum.rb', line 322
def lectures_from_indi4
obtain_lectures_from_this_curriculum(:indi4)
end
|
#lectures_from_the_bachelor_genetik_curriculum ⇒ Object
#
lectures_from_the_bachelor_genetik_curriculum
#
46
47
48
|
# File 'lib/studium/base/curriculum.rb', line 46
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
#
291
292
293
294
295
296
|
# File 'lib/studium/base/curriculum.rb', line 291
def lectures_from_the_individual_vektor_curricula
(
obtain_lectures_from_this_curriculum(:bachelor_vektor)+
obtain_lectures_from_this_curriculum(:master_vektor)
).flatten
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)
#
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/studium/base/misc.rb', line 110
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
826
827
828
|
# File 'lib/studium/base/misc.rb', line 826
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”, the 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).
#
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/studium/base/time.rb', line 77
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
|
#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.
#
83
84
85
|
# File 'lib/studium/base/misc.rb', line 83
def no_ext_name(i)
i.sub(/#{File.extname(i)}$/,'')
end
|
#no_file_at(i) ⇒ Object
Also known as:
no_file_exists_at
42
43
44
|
# File 'lib/studium/base/minimal_prototype.rb', line 42
def no_file_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.
#
254
255
256
257
258
|
# File 'lib/studium/base/time.rb', line 254
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)
#
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/studium/base/obtain.rb', line 24
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 base.rb, method: obtain() → No key found, "\
"called `#{this_key.to_s}` (class '#{this_key.class.to_s})"
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_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.
#
336
337
338
339
340
341
342
343
|
# File 'lib/studium/base/curriculum.rb', line 336
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_editor(i) ⇒ Object
#opnn(i = @namespace, &block) ⇒ Object
#
opnn
The method also handles blocks.
#
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/studium/base/opnn.rb', line 20
def opnn(
i = @namespace,
&block
)
if use_opn?
if i.is_a? String i = { namespace: i }
end
Opn.opn(i, &block)
end
end
|
#path_to_exam_topic? ⇒ Boolean
#
directory_to_the_exam_topics?
#
path_to_exam_topic?
#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) ⇒ Object
#
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.
#
883
884
885
886
887
888
889
890
891
892
893
894
|
# File 'lib/studium/base/misc.rb', line 883
def read_in_exam_dataset_from_this_file(
this_file
)
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)
dataset = filter_away_invalid_questions(dataset)
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()”.
#
359
360
361
362
363
|
# File 'lib/studium/base/misc.rb', line 359
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.
#
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/studium/base/readlines.rb', line 28
def readlines_from_this_input_file(
this_file,
use_this_encoding = :default_encoding
)
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
File.readlines(
this_file,
encoding: use_this_encoding
)
end
|
#register_sigint ⇒ Object
188
189
190
|
# File 'lib/studium/base/misc.rb', line 188
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.
#
320
321
322
323
324
|
# File 'lib/studium/base/misc.rb', line 320
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
#
228
229
230
|
# File 'lib/studium/base/colours.rb', line 228
def remove_escape_sequences(i)
::Colours.remove_escape_sequences(i)
end
|
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/studium/base/misc.rb', line 294
def (i)
if i.is_a? Array
i.map {|line|
if line.include? '#'
line = line[0 .. (line.index('#')-1)]
end
line.strip
}
end
end
|
308
309
310
311
312
|
# File 'lib/studium/base/misc.rb', line 308
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_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.
#
283
284
285
286
287
288
289
|
# File 'lib/studium/base/misc.rb', line 283
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
#
546
547
548
549
550
551
552
553
|
# File 'lib/studium/base/misc.rb', line 546
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
526
527
528
529
530
531
532
533
534
|
# File 'lib/studium/base/misc.rb', line 526
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?().
#
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/studium/base/replace.rb', line 43
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.
#
19
20
21
22
23
24
25
26
|
# File 'lib/studium/base/replace.rb', line 19
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
#
58
59
60
|
# File 'lib/studium/base/replace.rb', line 58
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.
#
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/studium/base/replace.rb', line 104
def replace_italic_token_with_this_colour(
i, use_this_colour = :mediumseagreen
)
use_this_regex = /<it?>([A-Za-zöäüÖÄÜ\s]+)<\/it?>/ 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,'')
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
#
65
66
67
|
# File 'lib/studium/base/replace.rb', line 65
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.
#
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/studium/base/replace.rb', line 74
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
|
#reset ⇒ Object
#
reset (reset tag)
The @runmode variable can be any of these three values:
:www
:gui
:commandline
If :commandline is used as its value, then this class may colourize via the Colours module - otherwise, it may colourize via “websafe” colours instead (such as the HTML colours).
Note that :gui means GUI, that is, graphical user interface. These are traditional “oldschool” desktop applications.
#
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/studium/base/reset.rb', line 31
def reset
@namespace = NAMESPACE
@be_verbose = true
@use_opn = true
@debug = false
@use_colours = ::Studium.use_colours?
@no_connection_to_the_www = false
set_mode :commandline end
|
#return_all_bachelor_lectures(from_this_dataset = ::Studium.main_dataset?) ⇒ Object
#
return_all_bachelor_lectures
This method will simply return all bachelor-lectures.
#
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/studium/base/curriculum.rb', line 272
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.
#
331
332
333
334
335
336
337
338
339
|
# File 'lib/studium/base/misc.rb', line 331
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
#
344
345
346
347
348
349
|
# File 'lib/studium/base/misc.rb', line 344
def return_all_steop_lectures
return_sanitized_dataset_from_the_file_lecture_information.select {|a, b|
is_a_steop_lecture = obtain(:steop, b)
is_a_steop_lecture
}
end
|
#return_current_year ⇒ Object
Also known as:
current_year?
#
return_current_year
This method will simply return the current year, as String.
#
164
165
166
|
# File 'lib/studium/base/time.rb', line 164
def return_current_year
Time.now.year.to_s
end
|
#return_dataset_for_this_topic(i) ⇒ Object
#
return_dataset_for_this_topic
#
539
540
541
|
# File 'lib/studium/base/misc.rb', line 539
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"}
#
474
475
476
477
478
479
480
481
482
483
484
485
486
|
# File 'lib/studium/base/misc.rb', line 474
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
#
197
198
199
200
201
202
203
204
|
# File 'lib/studium/base/colours.rb', line 197
def return_either_grey_or_the_custom_colour_for_answers
_ = grey('').strip
if @custom_colours and
@custom_colours.has_key?('colour_for_answers')
_ = COLOURS.send(@custom_colours['colour_for_answers']) { :omit_end }
end
_
end
|
#return_either_grey_or_the_custom_colour_for_questions ⇒ Object
#
return_either_grey_or_the_custom_colour_for_questions
#
298
299
300
301
302
303
304
305
|
# File 'lib/studium/base/colours.rb', line 298
def return_either_grey_or_the_custom_colour_for_questions
_ = grey('').strip
if @custom_colours and
@custom_colours.has_key?('colour_for_questions')
_ = COLOURS.send(@custom_colours['colour_for_questions']) { :omit_end }
end
_
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_file_associated_with_this_curriculum, location_of_this_curriculum_file?
#
return_file_for_this_curriculum
#
#return_german_name_for_this_english_month(i) ⇒ Object
#
return_german_name_for_this_english_month
#
#return_german_weekday_of?(i) ⇒ Boolean
#
return_german_weekday_of?
#
307
308
309
|
# File 'lib/studium/base/time.rb', line 307
def return_german_weekday_of?(i)
weekday?(i, :german)
end
|
#return_hh_mm_ss_from(i) ⇒ 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.
#
477
478
479
480
481
482
483
484
485
486
487
488
|
# File 'lib/studium/base/time.rb', line 477
def return_hh_mm_ss_from(i)
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.
#
512
513
514
515
516
|
# File 'lib/studium/base/time.rb', line 512
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
#
53
54
55
|
# File 'lib/studium/base/curriculum.rb', line 53
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).
#
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
|
# File 'lib/studium/base/misc.rb', line 391
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!(',')
time_parsed = Time.parse(exams)
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
#
41
42
43
44
45
|
# File 'lib/studium/base/time.rb', line 41
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
#
34
35
36
|
# File 'lib/studium/base/time.rb', line 34
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
require 'studium/toplevel_methods/return_n_questions_were_answered_for_this_topic.rb' ^^^ this is already required elsewhere.
#
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.
#
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
# File 'lib/studium/base/time.rb', line 280
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).
#
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/studium/base/curriculum.rb', line 193
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
724
725
726
727
728
729
730
731
|
# File 'lib/studium/base/misc.rb', line 724
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.
#
456
457
458
459
460
461
|
# File 'lib/studium/base/misc.rb', line 456
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?
129
130
131
|
# File 'lib/studium/base/misc.rb', line 129
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'.
#
157
158
159
|
# File 'lib/studium/base/misc.rb', line 157
def return_sanitized_dataset_from_the_file_lecture_information
Studium.return_sanitized_dataset_from_the_file_lecture_information
end
|
#return_solved_lectures ⇒ Object
#
return_solved_lectures
This method will return only those entries that have the key :already_solved set to true.
#
591
592
593
594
595
596
|
# File 'lib/studium/base/misc.rb', line 591
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.
#
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
# File 'lib/studium/base/misc.rb', line 259
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.
#
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/studium/base/prototype.rb', line 61
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
_
end
|
#return_title_from_this_curriculum_file(i, use_a_shorter_name = false) ⇒ Object
Also known as:
return_title_of
#
return_title_from_this_curriculum_file
The first argument to this method should be the abbreviation of that particular curriculum.
Usage example:
return_title_from_this_curriculum_file(:indi2)
#
#rev ⇒ Object
Also known as:
revert
287
288
289
290
291
292
293
|
# File 'lib/studium/base/colours.rb', line 287
def rev
if @use_colours
::Studium::Colours.rev
else
''
end
end
|
#right_arrow? ⇒ Boolean
91
92
93
|
# File 'lib/studium/base/unicode.rb', line 91
def right_arrow?
UNICODE_RIGHT_ARROW
end
|
#rinstall2 ⇒ Object
851
852
853
854
855
856
857
858
859
|
# File 'lib/studium/base/misc.rb', line 851
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?
#
77
78
79
|
# File 'lib/studium/base/prototype.rb', line 77
def roebe_exam_directory?
"#{RUBY_STUDIUM_HOME_DIR}exam_topics/"
end
|
#ruby_src_dir_at_home? ⇒ Boolean
#
ruby_src_dir_at_home?
#
#run ⇒ Object
14
15
|
# File 'lib/studium/base/run.rb', line 14
def run
end
|
#runmode? ⇒ Boolean
Also known as:
mode?
78
79
80
|
# File 'lib/studium/base/mode.rb', line 78
def runmode?
@runmode
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_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)
#
506
507
508
509
510
511
512
513
514
|
# File 'lib/studium/base/misc.rb', line 506
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_quiet ⇒ Object
819
820
821
|
# File 'lib/studium/base/misc.rb', line 819
def set_be_quiet
@be_verbose = false
end
|
#set_be_verbose ⇒ Object
Also known as:
be_verbose
812
813
814
|
# File 'lib/studium/base/misc.rb', line 812
def set_be_verbose
@be_verbose = true
end
|
#set_commandline_arguments(i = ARGV) ⇒ Object
#
set_commandline_arguments
The commandline arguments are always an Array.
#
16
17
18
19
20
21
|
# File 'lib/studium/base/commandline_arguments.rb', line 16
def set_commandline_arguments(
i = ARGV
)
i = [i].flatten.compact
@commandline_arguments = i
end
|
#set_commandline_mode ⇒ Object
Also known as:
set_commandline
52
53
54
|
# File 'lib/studium/base/mode.rb', line 52
def set_commandline_mode
set_mode :commandline
end
|
#set_runmode(i = ::Studium::Exams.runmode?) ⇒ Object
Also known as:
set_mode
#
set_runmode
This method will delegate towards Exams.set_runmode.
We have three valid modes, which can be passed as argument to this method here, as a Symbol:
(1) :commandline
(2) :www
(3) :gui
The default one is :commandline.
We tap into the class-method Exams.runmode? by default, which will be equal to passing :commandline.
#
#set_this_cd_alias_to(cd_alias, new_content, be_verbose = :default) ⇒ Object
#set_www_mode ⇒ Object
Also known as:
www_mode
#
set_www_mode
Set to :www runmode through this method.
#
71
72
73
|
# File 'lib/studium/base/mode.rb', line 71
def set_www_mode
set_runmode :www
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
353
354
355
|
# File 'lib/studium/base/time.rb', line 353
def show_todays_date
e 'Today is the '+slateblue(today?)+' ('+lightgreen(weekday?)+')'; e
end
|
#sort_these_lecture_names_by_time(array, weekday) ⇒ Object
#
sort_these_lecture_names_by_time
#
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
# File 'lib/studium/base/time.rb', line 521
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
|
#swarn(i = '') ⇒ Object
220
221
222
223
|
# File 'lib/studium/base/colours.rb', line 220
def swarn(i = '')
return ::Colours.swarn(i) if @use_colours
return i
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.
#
174
175
176
177
178
179
180
181
|
# File 'lib/studium/base/time.rb', line 174
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'.
#
268
269
270
271
272
|
# File 'lib/studium/base/time.rb', line 268
def translate_dd_mm_yyyy_to_weekday(
i = '25.02.2020'
)
weekday?(i)
end
|
#try_to_require_the_rcfiles ⇒ Object
#
try_to_require_the_rcfiles
#
899
900
901
902
903
|
# File 'lib/studium/base/misc.rb', line 899
def try_to_require_the_rcfiles
begin
require 'rcfiles'
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.
#
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/studium/base/misc.rb', line 66
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 }}
#
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/studium/base/unicode.rb', line 47
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
_ = ::Colours::AllColourMethods.send(optional_use_this_colour, _)
end
return _
end
|
#use_colours? ⇒ Boolean
280
281
282
|
# File 'lib/studium/base/colours.rb', line 280
def use_colours?
@use_colours
end
|
#use_opn? ⇒ Boolean
35
36
37
|
# File 'lib/studium/base/opnn.rb', line 35
def use_opn?
@use_opn
end
|
#vertical_bar? ⇒ Boolean
77
78
79
|
# File 'lib/studium/base/unicode.rb', line 77
def vertical_bar?
return '|'
end
|
#web_liner(this_token = '*') ⇒ Object
656
657
658
|
# File 'lib/studium/base/misc.rb', line 656
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.
#
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
|
# File 'lib/studium/base/time.rb', line 582
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) ⇒ Object
Also known as:
store_what_into
#
write_what_into
Use this method to save data into a specific file.
#
632
633
634
|
# File 'lib/studium/base/misc.rb', line 632
def write_what_into(what, into)
Studium.write_what_into(what, into)
end
|
#www_connection_is_unavailable ⇒ Object
Also known as:
www_is_unavailable
#
www_connection_is_unavailable
#
679
680
681
|
# File 'lib/studium/base/misc.rb', line 679
def www_connection_is_unavailable
@no_connection_to_the_www = true
end
|
#www_mode? ⇒ Boolean
Also known as:
is_on_www?, are_we_in_www_mode?, in_www_mode?
#
www_mode?
This method will return true if we run in www mode.
#
87
88
89
|
# File 'lib/studium/base/mode.rb', line 87
def www_mode?
runmode? == :www
end
|
#yaml_dir? ⇒ Boolean
40
41
42
|
# File 'lib/studium/base/prototype.rb', line 40
def yaml_dir?
Studium.yaml_directory?
end
|