Class: Studium::SearchFor_nECTS
- Inherits:
-
Base
- Object
- Base
- Studium::SearchFor_nECTS
show all
- Defined in:
- lib/studium/ects/search_for_n_ects.rb
Overview
Constant Summary
collapse
- NAMESPACE =
'SearchFor_nECTS'
Constants inherited
from Base
Base::ARRAY_HTML_COLOURS_IN_USE, Base::CHECK_FOR_INCORRECT_ENTRIES_IN_THE_QUESTION_ANSWER_FILE_THAT_SHOULD_BE_COMMENTS, Base::COLOURS, Base::COMMON_YEAR_DAYS_IN_MONTH, Base::GRAY, Base::LEFT_PADDING, Base::N_CHARACTERS_PER_LINE, Base::UNICODE_RIGHT_ARROW
Constants included
from Colours
Colours::COLOURS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#add_proper_year_entry_to_this_line, #already_solved_this_lva_number?, #append_what_into, #available_topics_as_short_name, #average_grade, #bachelor_master_or_diploma, #base_dir?, #be_silent, #be_verbose?, #beautiful_url, #change_directory, #cheering_person, #cliner, #colour_for_ects_points, #colourize_percentage, #commandline_arguments?, #commandline_arguments_joined, #commandline_arguments_with_hyphens?, #convert_this_array_of_lectures_into_the_full_dataset, #copy, #cpruby, #create_directory, #create_file, #csv_file?, #current_month?, #datum?, #day_month_year, #debug?, #delete_file, #directory_of_the_exam_topics?, #directory_to_my_exam_topics, #directory_to_the_exam_topics?, #disable_colours, #disable_colours_globally, #do_not_be_verbose, #do_not_use_opn, #do_these_curricula_include_both_a_bachelor_and_a_master_curriculum?, #does_this_line_include_a_german_weekday?, #does_this_line_include_a_html_colour?, #e, #ecomment, #editor?, #ee, #enable_colours, #enable_colours_globally, #enable_debug, #encoding?, #english_to_german_weekday, #ensure_main_encoding, #ensure_that_the_log_directory_exists, #eparse, #erev, #esystem, #etomato, #exit_program, #expand_topic, #extract_dd_mm_yyyy, #file_lecture_information?, #file_read_with_proper_encoding, #filter_away_invalid_questions, #find_corresponding_exam_topic, #first_argument?, #first_non_hyphen_argument?, #from_curriculum_id_to_university, #german_date_notation, #german_weekday?, #german_weekdays?, #has_a_bachelor_curriculum?, #has_a_master_curriculum?, #has_this_exam_topic_been_solved?, #has_year_entry?, #hh_mm_ss_dd_mm_yyyy, #horizontal_bar?, #html_log_directory?, #is_a_master_lecture?, #is_a_weekday?, #is_connected_to_the_www?, #is_on_roebe?, #is_prüfungsimmanent?, #is_this_a_valid_html_colour?, #is_this_day_today?, #konsole_support?, #last_file?, #lectures_from_indi1, #lectures_from_indi2, #lectures_from_indi3, #lectures_from_indi4, #lectures_from_the_bachelor_genetik_curriculum, #lectures_from_the_individual_vektor_curricula, #load_yaml_dataset, #move_file, #n_days_difference_from_today_to_this_day, #no_ext_name, #no_file_at, #number_to_month, #obtain, #obtain_lectures_from_this_curriculum, #open_in_editor, #opnn, #path_to_exam_topic?, #read_dataset_from_a_curriculum_file, #read_in_exam_dataset_from_this_file, #read_this_file_with_default_encoding, #readlines_from_this_input_file, #register_sigint, #remove_empty_strings, #remove_escape_sequences, #remove_internal_comments, #remove_leading_comments, #remove_leading_weekday_names_from, #remove_newlines, #remove_tags_from_this_input, #rename_kde_konsole_tab, #rename_konsole_tab?, #replace_all_html_colours_in_this, #replace_bold_token_with_default_colour, #replace_italic_token_with_default_colour, #replace_italic_token_with_this_colour, #replace_regular_numbers_with_unicode_numbers, #replace_underline_token_with_default_colour, #replace_underline_token_with_this_colour, #return_all_bachelor_lectures, #return_all_exams_on_this_day, #return_all_numbers_from, #return_all_registered_curricula, #return_all_steop_lectures, #return_current_year, #return_dataset_for_this_topic, #return_dataset_from_this_curriculum_file, #return_dd_mm_yy_and_time_from, #return_directory_for, #return_ects_points_from_these_lectures, #return_either_grey_or_the_custom_colour_for_answers, #return_either_grey_or_the_custom_colour_for_questions, #return_file_for_this_curriculum, #return_german_name_for_this_english_month, #return_german_weekday_of?, #return_hh_mm_ss_from, #return_hour_from_this, #return_lectures_from_bachelor_vektor_curriculum, #return_lectures_with_at_the_least_one_upcoming_exam, #return_local_path_of_this_pwdstud, #return_lva_number_of_this_lecture, #return_month_fitting_to_this_input, #return_n_days_until_monday, #return_n_days_until_sunday, #return_n_exam_questions_in, #return_n_questions_were_answered_for_this_topic, #return_name_of_the_weekday, #return_name_of_this_curriculum, #return_name_of_this_curriculum_based_on_its_id_number, #return_opnn, #return_passed_courses, #return_pwd, #return_random_curriculum, #return_sanitized_dataset_from_the_file_lecture_information, #return_solved_lectures, #return_steop_lectures, #return_the_remote_homepage_url, #return_this_line_has_n_characters_as_html_colour_tags, #return_title_from_this_curriculum_file, #rev, #right_arrow?, #rinstall2, #roebe_exam_directory?, #ruby_src_dir_at_home?, #runmode?, #sanitize_this_topic, #sanitize_url, #select_lectures_with_this_key, #set_be_quiet, #set_be_verbose, #set_commandline_arguments, #set_commandline_mode, #set_runmode, #set_this_cd_alias_to, #set_www_mode, #sfancy, #shall_we_make_use_of_unicode_symbols?, #show_todays_date, #simp, #sort_these_lecture_names_by_time, #spacer, #swarn, #this_month_has_n_days?, #total_ects_points_passed, #translate_dd_mm_yyyy_to_weekday, #try_to_require_the_rcfiles, #turn_this_array_into_the_full_dataset, #unicode_blocks_line, #use_colours?, #use_opn?, #vertical_bar?, #web_liner, #weekday?, #weekdays?, #word_wrap, #write_what_into, #www_connection_is_unavailable, #www_mode?, #yaml_dir?
Methods included from Colours
#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, #sfancy, sfile, #sfile, simp, #simp, slateblue, steelblue, #steelblue, #swarn, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow
Constructor Details
#initialize(i = nil, run_already = true) ⇒ SearchFor_nECTS
42
43
44
45
46
47
48
49
50
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 42
def initialize(
i = nil,
run_already = true
)
reset
i = set_commandline_arguments_and_return_leftover(i)
set_select_for_n_ects_points(i)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
532
533
534
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 532
def self.[](i = '')
new(i)
end
|
Instance Method Details
#append_to_the_commandline(i) ⇒ Object
#
append_to_the_commandline
#
122
123
124
125
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 122
def append_to_the_commandline(i)
@commandline_arguments << i
@commandline_arguments.flatten!
end
|
#apply_filters_should_they_exist ⇒ Object
#
apply_filters_should_they_exist
#
442
443
444
445
446
447
448
449
450
451
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 442
def apply_filters_should_they_exist
if @apply_this_filter
case @apply_this_filter when :only_master_lectures
@current_dataset = return_only_master_lectures_from_this_dataset(@current_dataset)
when :only_bachelor_lectures
@current_dataset = return_only_bachelor_lectures_from_this_dataset(@current_dataset)
end
end
end
|
#colourize_the_lecture_type_in_crimson_or_in_brown(i) ⇒ Object
#
colourize_the_lecture_type_in_crimson_or_in_brown
#
346
347
348
349
350
351
352
353
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 346
def colourize_the_lecture_type_in_crimson_or_in_brown(i)
case i.strip
when 'B'
crimson(i)
else
brown(i)
end
end
|
#colourized_display_of_this_matching_lecture(name, inner_hash) ⇒ Object
#
colourized_display_of_this_matching_lecture
The second argument to this method is the Hash that contains all the useful information from the file “lecture_information.yml”.
#
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 483
def colourized_display_of_this_matching_lecture(
name, inner_hash
)
curricula_entry = inner_hash['curricula']
at_this_university = inner_hash[:university]
lecture_type = inner_hash[:type]
shorter_name_of_the_lecture = name.split(' ')[1..-1].join(' ').strip
if @show_numbers
shorter_name_of_the_lecture = name
end
padded_index = ("#{@index_counter.to_s})").rjust(4)
colourized_and_padded_index = slateblue(padded_index)
e colourized_and_padded_index+' '+
sfancy(shorter_name_of_the_lecture.ljust(88))+' '+ colourize_the_lecture_type_in_crimson_or_in_brown(
report_bachelor_or_master_curricula(curricula_entry).ljust(5)
)+
mediumseagreen(at_this_university.center(12))+' '+
mediumturquoise("[#{lecture_type.to_s}]")
end
|
#current_dataset? ⇒ Boolean
#
current_dataset?
This is the dataset we are working with.
#
139
140
141
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 139
def current_dataset?
@current_dataset
end
|
#is_a_bachelor_lecture?(i) ⇒ Boolean
Also known as:
has_a_bachelor_lecture?
#
is_a_bachelor_lecture?
Input to this method must be an Array.
This method will return a boolean depending on whether the given input is a bachelor-curriculum or whether it is not.
The lecture is assumed to be a bachelor curriculum if it starts with any of the following input:
'033'
'193'
'198'
#
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 424
def is_a_bachelor_lecture?(i)
result = false
if i
result = i.any? {|entry|
entry.start_with?('033') or
entry.start_with?('193') or
entry.start_with?('198')
}
else
e 'No value was supplied. Call stack is:'; print ' '
pp caller()
end
return result
end
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 160
def (
i = @commandline_arguments
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?show(-|_)?numbers$/i,
/^-?-?numbers$/i
@show_numbers = true
when /^-?-?only(-|_)?master$/,
/^-?-?master$/
@apply_this_filter = :only_master_lectures
when /^-?-?prüfungsimmanent\??/i,
/^-?-?mandatory\??/i
@current_dataset.select! {|name_of_the_lecture, inner_dataset|
type = inner_dataset[:type]
is_prüfungsimmanent? type
}
when /^-?-?only(-|_)?bachelor$/,
/^-?-?bachelor$/
@apply_this_filter = :only_bachelor_lectures
when /help/
show_help
exit
end
end
end
|
#notify_the_user_if_we_have_not_found_any_lecture_that_fits ⇒ Object
#
notify_the_user_if_we_have_not_found_any_lecture_that_fits
#
378
379
380
381
382
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 378
def notify_the_user_if_we_have_not_found_any_lecture_that_fits
unless @have_we_found_any_lecture_that_fits
e "No result was found for #{sfancy(n_ects_points?)} ECTS points."
end
end
|
#original_dataset? ⇒ Boolean
130
131
132
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 130
def original_dataset?
@original_dataset
end
|
#report_bachelor_or_master_curricula(i) ⇒ Object
#
report_bachelor_or_master_curricula
The input to this method should be an Array holding the dataset for the Curricula (Bachelor or Master).
If it is part of a bachelor curriculum then a 'B' will be appended to the resulting string; if it is a master curriculum then a 'M' will be appended.
#
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 279
def report_bachelor_or_master_curricula(i)
result = ''.dup
if i
if i.any? {|entry|
entry.start_with?('033')
}
result << 'B'
end
if i.any? {|entry|
entry.start_with?('066')
}
unless result.empty?
result << '/' end
result << 'M'
end
else
e 'No value was supplied. Call stack is:'
pp caller()
end
return result
end
|
#reset ⇒ Object
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
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 55
def reset
super()
@namespace = NAMESPACE
@original_dataset = dataset_from_file_lecture_information
@index_counter = 0 @have_we_found_any_lecture_that_fits = false
@apply_this_filter = nil
@show_numbers = true
@commandline_arguments = []
end
|
#return_lecture_is_or_lecture_are(i) ⇒ Object
#
return_lecture_is_or_lecture_are
#
335
336
337
338
339
340
341
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 335
def return_lecture_is_or_lecture_are(i)
if i > 1
'lectures are'
else
'lecture is'
end
end
|
#return_only_bachelor_lectures_from_this_dataset(i) ⇒ Object
#
return_only_bachelor_lectures_from_this_dataset
#
468
469
470
471
472
473
474
475
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 468
def return_only_bachelor_lectures_from_this_dataset(i)
i.select {|name, hash|
curricula = hash['curricula']
curricula.any? {|most_inner_entry|
most_inner_entry.start_with? '033'
}
}
end
|
#return_only_master_lectures_from_this_dataset(i) ⇒ Object
#
return_only_master_lectures_from_this_dataset
#
456
457
458
459
460
461
462
463
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 456
def return_only_master_lectures_from_this_dataset(i)
i.select {|name, hash|
curricula = hash['curricula']
curricula.any? {|most_inner_entry|
most_inner_entry.start_with? '066'
}
}
end
|
#run ⇒ Object
514
515
516
517
518
519
520
521
522
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 514
def run
select_all_entries_that_match_the_criterium
apply_filters_should_they_exist
try_to_report_those_entries_first_that_were_already_passed
try_to_report_unfinished_bachelor_entries_that_match
try_to_report_unfinished_master_entries_that_match
notify_the_user_if_we_have_not_found_any_lecture_that_fits
end
|
#select_all_entries_that_match_the_criterium ⇒ Object
#
select_all_entries_that_match_the_criterium
This is a general filter where we obtain the lectures that can match to the given n ECTS criterium.
#
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 390
def select_all_entries_that_match_the_criterium
select_for_n_ects_points = select_for_n_ects_points?
@current_dataset = original_dataset?.select {|name_of_the_lecture, inner_hash|
n_ects_points = inner_hash[:ects]
curricula = inner_hash['curricula']
if @apply_this_filter == :only_master_lectures
(select_for_n_ects_points == n_ects_points) and has_a_master_curriculum?(curricula)
elsif @apply_this_filter == :only_bachelor_lectures
(select_for_n_ects_points == n_ects_points) and has_a_bachelor_curriculum?(curricula)
else
select_for_n_ects_points == n_ects_points
end
}
end
|
#select_for_n_ects_points? ⇒ Boolean
Also known as:
seeking_n_ects_points?, n_ects_points?
#
select_for_n_ects_points?
#
210
211
212
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 210
def select_for_n_ects_points?
@select_for_n_ects_points
end
|
#set_commandline_arguments_and_return_leftover(i) ⇒ Object
#
set_commandline_arguments_and_return_leftover
#
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 106
def set_commandline_arguments_and_return_leftover(i)
if i.any? {|entry|
entry.to_s.start_with? '--'
}
selection = i.select {|inner_entry|
inner_entry.to_s.start_with? '--'
}
append_to_the_commandline(selection)
i.reject! {|unwanted_entries| unwanted_entries.to_s.start_with? '--' }
end if i.respond_to? :any?
i
end
|
#set_select_for_n_ects_points(i = '') ⇒ Object
#
set_select_for_n_ects_points
#
97
98
99
100
101
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 97
def set_select_for_n_ects_points(i = '')
i = [i] unless i.is_a? Array
i = i.first.to_s.to_f
@select_for_n_ects_points = i
end
|
#show_help ⇒ Object
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 146
def show_help
e
e ' --only-bachelor # show only bachelor-lectures'
e ' --only-master # show only master-lectures'
e ' --prüfungsimmanent? # show only "prüfungsimmanente" '\
'lectures (== mandatoy presence courses)'
e ' --show-numbers # If this flag is used then the '\
'leading LVA ID numbers are shown as well.'
e
end
|
#try_to_report_those_entries_first_that_were_already_passed ⇒ Object
#
try_to_report_those_entries_first_that_were_already_passed
#
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 218
def try_to_report_those_entries_first_that_were_already_passed
_ = @current_dataset.select {|name, inner_hash|
inner_hash[:already_solved]
}
if _.empty?
else
@have_we_found_any_lecture_that_fits = true
e
if @apply_this_filter
case @apply_this_filter
when :only_master_lectures
_ = return_only_master_lectures_from_this_dataset(_)
when :only_bachelor_lectures
_ = return_only_bachelor_lectures_from_this_dataset(_)
end
end
result = ("#{rev}The following #{sfancy(_.size.to_s)}").dup
if _.size > 1
result << ' lectures have '
else
result << ' lecture has '
end
result << lightskyblue(seeking_n_ects_points?.to_s)+' ECTS point '\
'and '
if _.size > 1
result << 'were'
else
result << 'was'
end
result << ' already passed:'
e result
e
_.each {|name, inner_hash| @index_counter += 1 colourized_display_of_this_matching_lecture(name, inner_hash)
}
e
@current_dataset.reject! {|name, inner_hash|
inner_hash[:already_solved]
}
end
end
|
#try_to_report_unfinished_bachelor_entries_that_match ⇒ Object
#
try_to_report_unfinished_bachelor_entries_that_match
#
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 305
def try_to_report_unfinished_bachelor_entries_that_match
return if @apply_this_filter == :only_master_lectures
selection = @current_dataset.select {|name, inner_hash|
curricula = inner_hash['curricula']
is_a_bachelor_lecture?(curricula)
}
if selection.empty?
else
@have_we_found_any_lecture_that_fits = true
e rev+'The following '+sfancy(selection.size.to_s)+
' '+return_lecture_is_or_lecture_are(selection.keys.size)+
' part of a '+mediumpurple('bachelor curriculum')+'.'
e
selection.each {|name, inner_hash| @index_counter += 1 colourized_display_of_this_matching_lecture(name, inner_hash)
}
e
@current_dataset.reject! {|name, inner_hash|
curricula = inner_hash['curricula']
is_a_bachelor_lecture?(curricula)
}
end
end
|
#try_to_report_unfinished_master_entries_that_match ⇒ Object
#
try_to_report_unfinished_master_entries_that_match
#
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
# File 'lib/studium/ects/search_for_n_ects.rb', line 358
def try_to_report_unfinished_master_entries_that_match
_ = @current_dataset
return if @apply_this_filter == :only_bachelor_lectures
if _.empty?
else
@have_we_found_any_lecture_that_fits = true
e "#{rev}The following #{sfancy(_.size.to_s)}"\
" #{return_lecture_is_or_lecture_are(_.size)}"\
" part of a #{mediumpurple('master curriculum')} only."
e
_.each {|name, inner_hash| @index_counter += 1 colourized_display_of_this_matching_lecture(name, inner_hash)
}
e
end
end
|