Class: Studium::WeekParser
- Inherits:
-
Base
- Object
- Base
- Studium::WeekParser
show all
- Defined in:
- lib/studium/utility_scripts/week_parser/run.rb,
lib/studium/utility_scripts/week_parser/help.rb,
lib/studium/utility_scripts/week_parser/menu.rb,
lib/studium/utility_scripts/week_parser/misc.rb,
lib/studium/utility_scripts/week_parser/show.rb,
lib/studium/utility_scripts/week_parser/reset.rb,
lib/studium/utility_scripts/week_parser/constants.rb,
lib/studium/utility_scripts/week_parser/week_parser.rb
Overview
Constant Summary
collapse
- NAMESPACE =
inspect
- SKIP_LOW_PRIORITY_LECTURES =
#
SKIP_LOW_PRIORITY_LECTURES
If true then we will skip low priority lectures.
#
true
- PAD_TO_THE_RIGHT =
99
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
-
.[](i = '') ⇒ Object
# === Studium::WeekParser[] ========================================================================= #.
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) ⇒ WeekParser
36
37
38
39
40
41
42
43
|
# File 'lib/studium/utility_scripts/week_parser/week_parser.rb', line 36
def initialize(
i = nil,
run_already = true
)
reset
set_commandline_arguments(i)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
Studium::WeekParser[]
#
369
370
371
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 369
def self.[](i = '')
new(i)
end
|
Instance Method Details
#colourize_lecture_day(first_date, priority = 1) ⇒ Object
#
colourize_lecture_day
The second argument is the priority of the lecture. Lectures with a higher priority will be brighter in colour (this is the part that will appear on the very left-hand side).
#
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 30
def colourize_lecture_day(
first_date, priority = 1
)
priority = priority.to_i
case priority
when 1
return yellowgreen(first_date)
when 4,5
return darkgreen(first_date)
else
return darkolivegreen(first_date)
end
end
|
#colourized_priority(priority, use_this_colour = :slateblue) ⇒ Object
#
colourized_priority
The priority 1 will be colourized via powderblue. The surrounding '(' and ')' will be in royalblue.
#
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 232
def colourized_priority(
priority, use_this_colour = :slateblue
)
result = royalblue('(Priorität: ').dup
case use_this_colour
when :honour_priority_value case priority.to_s
when '1'
result << lightseagreen(priority.to_s)
else
result << slateblue(priority.to_s)
end
when :slateblue
result << slateblue(priority.to_s)
when :red, :exam, :warning
result << crimson(priority.to_s)
end
result << royalblue(')')
return result
end
|
#dataset? ⇒ Boolean
325
326
327
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 325
def dataset?
@dataset
end
|
318
319
320
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 318
def dataset_lecture_information?
@dataset
end
|
#determine_the_weekday_from(i = 'Mittwoch 14.03.2018') ⇒ Object
#
determine_the_weekday_from
#
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 119
def determine_the_weekday_from(
i = 'Mittwoch 14.03.2018'
)
return i unless i
if i.include? ' ' i = i.split(' ').last
end
parsed_time = Time.parse(i)
weekday = parsed_time.wday
case weekday
when 1
:monday
when 2
:tuesday
when 3
:wednesday
when 4
:thursday
when 5
:friday
when 6
:saturday
end
end
|
#exams_on_this_day(i) ⇒ Object
12
13
14
15
16
17
18
19
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/utility_scripts/week_parser/menu.rb', line 12
def (
i = commandline_arguments?
)
if i.is_a? Array
i.each {|entry| (entry) }
else
case i when /^-?-?unrestricted$/,
/^-?-?infinity$/
opnn; e 'Showing many more lectures next.'
@n_days_into_the_future = 300
when /-?-?debug$/
@debug = true
when /-?-?help/
show_help
exit
else if is_a_weekday?(i.delete('-'))
this_weekday = i.delete('-')
if GERMAN_TO_ENGLISH_WEEKDAYS.has_key? this_weekday
this_weekday = GERMAN_TO_ENGLISH_WEEKDAYS[this_weekday]
end
this_weekday = this_weekday.downcase.to_sym
@array_show_these_days = [
this_weekday
]
end
end
end
end
|
#populate_hash_weekly_lectures_with_these_lectures(hash) ⇒ Object
#
populate_hash_weekly_lectures_with_these_lectures
We may reject entries that are not within the next e. g. 30 coming days.
Additionally, entries that have old lva_dates should be disregarded as well. In these case, we may try to locate a new lva-date entry.
#
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 153
def populate_hash_weekly_lectures_with_these_lectures(hash)
hash_weekly_lectures = @hash_weekly_lectures
maximum_allowed_time_in_the_future = return_n_days(@n_days_into_the_future) hash.each_pair {|name_of_the_lecture, inner_hash|
pointer = { name_of_the_lecture => inner_hash }
all_lva_dates = inner_hash['lva_dates']
if all_lva_dates.nil?
opnn; e 'No lva-entry found for '+sfancy(name_of_the_lecture)
next
end
first_lva_date = all_lva_dates.first.squeeze(' ')
splitted = first_lva_date.split(',').map(&:strip)
this_date = splitted.first
this_time_on_that_day = splitted.last weekday_to_be_used_as_symbol = determine_the_weekday_from(this_date) this_date = remove_weekdays_from(this_date).strip current_time = Time.now
begin
time_of_that_date = Time.parse("#{this_date} #{this_time_on_that_day}")
rescue Exception => error
e orange(name_of_the_lecture)
pp inner_hash
pp error
pp error.class
pp '^^^ TODO: add this exception specifically'
end
if time_of_that_date > maximum_allowed_time_in_the_future
next
end
if (current_time - (ONE_DAY - 1) ) > time_of_that_date
if @debug
opnn; e 'There is an old date entry at '+sfancy(this_date)+
' for '+simp(name_of_the_lecture)
end
end
if hash_weekly_lectures.has_key?(weekday_to_be_used_as_symbol)
hash_weekly_lectures[weekday_to_be_used_as_symbol].update(pointer)
else
opnn; e 'No key ('+orange('weekday-key')+') was found for `'+
sfancy(name_of_the_lecture)+'`.'
opnn; e "The date entry was #{sfancy(this_date.to_s)}"
end
}
end
|
#remove_weekdays_from(i) ⇒ Object
#report_weekly_lectures ⇒ Object
#
report_weekly_lectures
#
12
13
14
15
16
17
18
19
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
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 12
def report_weekly_lectures
opnn; e "Next showing the #{mediumpurple('weekly lectures')}:"; e
_ = @hash_weekly_lectures
monday = _[:monday]
tuesday = _[:tuesday]
wednesday = _[:wednesday]
thursday = _[:thursday]
friday = _[:friday]
if show_monday?
unless monday.empty?
show_this_weekday(monday, 'Monday')
end
end
if show_tuesday?
unless tuesday.empty?
show_this_weekday(tuesday, 'Tuesday')
end
end
if show_wednesday?
unless wednesday.empty?
show_this_weekday(wednesday, 'Wednesday')
end
end
if show_thursday?
unless thursday.empty?
show_this_weekday(thursday, 'Thursday')
end
end
if show_friday?
unless friday.empty?
show_this_weekday(friday, 'Friday')
end
end
end
|
#reset ⇒ Object
12
13
14
15
16
17
18
19
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
58
59
60
61
62
63
64
65
66
|
# File 'lib/studium/utility_scripts/week_parser/reset.rb', line 12
def reset
super()
@namespace = NAMESPACE
@n_days_into_the_future = 36
@skip_low_priority_lectures = SKIP_LOW_PRIORITY_LECTURES
@pad_to_the_right = PAD_TO_THE_RIGHT
@dataset = Studium.return_sanitized_dataset_from_file_lecture_information
@hash_weekly_lectures = {}
@debug = false
%i{
monday tuesday wednesday thursday friday saturday
}.each {|this_day| @hash_weekly_lectures[this_day] = {} }
@array_show_these_days = %i(
monday tuesday wednesday thursday friday
)
end
|
#return_exams_on_this_day(dd_mm_yyyy = '23.04.2018') ⇒ Object
#
return_exams_on_this_day
#
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 332
def return_exams_on_this_day(
dd_mm_yyyy = '23.04.2018'
)
start_date = Time.parse(dd_mm_yyyy)
end_date = start_date + (ONE_DAY - 1)
range = start_date .. end_date
selection = @dataset.select {|name, inner_hash|
if inner_hash.has_key?('registered')
upcoming_exam = inner_hash['registered'].first
upcoming_exam = remove_leading_weeknames(upcoming_exam)
if upcoming_exam.include? ', Ort'
upcoming_exam = upcoming_exam.split(', Ort').first.delete(',')
end
_ = Time.parse(upcoming_exam).to_i
range.cover? _
else
false
end
}
selection end
|
#return_german_name_from_this_english_name(i) ⇒ Object
#
return_german_name_from_this_english_name
#
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 47
def return_german_name_from_this_english_name(i)
case i.downcase
when 'monday'
'Montag'
when 'tuesday'
'Dienstag'
when 'wednesday'
'Mittwoch'
when 'thursday'
'Donnerstag'
when 'friday'
'Freitag'
end
end
|
#return_n_days(i = 30) ⇒ Object
#
return_n_days
Look n days into the future.
#
112
113
114
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 112
def return_n_days(i = 30)
Time.now + (ONE_DAY * i)
end
|
#run ⇒ Object
12
13
14
15
16
|
# File 'lib/studium/utility_scripts/week_parser/run.rb', line 12
def run
select_entries_that_contain_lva_dates
report_weekly_lectures
end
|
#select_entries_that_contain_lva_dates ⇒ Object
#
select_entries_that_contain_lva_dates
We will ONLY select entries that contain lva_dates and were NOT already solved.
#
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
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 68
def select_entries_that_contain_lva_dates
lva_dates = dataset?.select {|name_of_the_lecture, hash_dataset|
if hash_dataset.nil?
opnn; e "Error for the lecture #{sfancy(name_of_the_lecture)}"
end
priority = hash_dataset[:priority]
unless priority.to_s =~ /^\d+$/
opnn; e 'Not a number for '+orange('priority')+': '+sfancy(priority.to_s)+
' (lecture: '+slateblue(name_of_the_lecture.to_s)+')'
end
already_solved = hash_dataset[:already_solved]
not_already_solved = !already_solved
if priority.nil? and not_already_solved
opnn; e "The lecture #{sfancy(name_of_the_lecture)} "\
"has no registered :priority entry."
end
if @skip_low_priority_lectures and priority and (priority > 4)
false
else
hash_dataset.has_key?('lva_dates') and not_already_solved
end
}
populate_hash_weekly_lectures_with_these_lectures(lva_dates)
end
|
#show_friday? ⇒ Boolean
81
82
83
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 81
def show_friday?
@array_show_these_days.include? :friday
end
|
#show_help ⇒ Object
#
show_help (help tag)
To invoke this method, do:
weekparse --help
#
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/studium/utility_scripts/week_parser/help.rb', line 17
def show_help
result = <<EOF
Presently, the following options are available:
--debug # show additional (debug) information
--unrestricted # do not limit showing lectures based on time
# date (thus, +300 days into the future)
You can also pass in the weekday such as "Montag", "Monday" or
"--Monday". The default for @n_days_into_the_future is #{steelblue(@n_days_into_the_future)}.
EOF
opnn; e result
end
|
#show_monday? ⇒ Boolean
#
show_monday? (monday tag, montag tag)
#
53
54
55
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 53
def show_monday?
@array_show_these_days.include? :monday
end
|
#show_this_weekday(hash_for_this_weekday, name_of_the_day = 'Monday') ⇒ Object
#
show_this_weekday
Use this method to display all lectures on a given day.
#
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 90
def show_this_weekday(
hash_for_this_weekday,
name_of_the_day = 'Monday'
)
this_is_the_weekday = hash_for_this_weekday.sort_by {|name_of_the_lecture, inner_hash|
lva_dates = inner_hash['lva_dates']
first_date = remove_leading_weekday_names_from(lva_dates.first)
Time.parse(first_date.delete(','))
}
result = sfancy(
name_of_the_day+
' ('+
return_german_name_from_this_english_name(name_of_the_day)+
')'+':' ).dup
if this_weekday_is_today?(name_of_the_day)
result << ' '+swarn("(This is today, the #{day_month_year})")
else time_now = Time.now
n_days_difference = n_days_difference_from_today_to_this_day(
time_now, name_of_the_day
)
result = result.ljust(48)
result << slateblue(" (in +#{n_days_difference} day")
result << slateblue('s') unless n_days_difference.to_i == 1
result << slateblue(')')
future_time = (time_now - 1) + (n_days_difference * ONE_DAY)
future_time_in_dd_mm_yyyy = "(#{return_day_month_year(future_time)})"
colourized_future_time = sfancy(future_time_in_dd_mm_yyyy)
result << " #{colourized_future_time}"
end
e result; e is_a_holiday = false
if future_time_in_dd_mm_yyyy
upcoming_exams = exams_on_this_day(
future_time_in_dd_mm_yyyy.delete('()')
)
end
if upcoming_exams
leading_notifier = swarn(' [REGISTERED FOR THIS EXAM]')
upcoming_exams = upcoming_exams.select {|name_of_the_lecture, inner_hash|
inner_hash.has_key? 'registered_for_an_upcoming_exam_at'
}
upcoming_exams.each {|name_of_the_lecture, inner_hash|
exam_time = inner_hash['exams'].first.split(',').last.strip
this_university = inner_hash[:university]
colourized_this_university = powderblue(' '+this_university)
colourized_name_of_the_lecture = slateblue(
name_of_the_lecture.ljust(69)
)
e leading_notifier+' '+
colourized_name_of_the_lecture+' '+
mediumslateblue('['+exam_time+']')+
colourized_this_university
}
end
this_is_the_weekday.each {|name_of_the_lecture, inner_hash|
lva_dates = inner_hash['lva_dates']
priority = inner_hash[:priority]
lecture_type = "[#{inner_hash[:type]}]"
first_date = lva_dates.first.strip if priority.nil?
opnn; e swarn('No priority entry was found for ')+
sfancy(name_of_the_lecture)
end
dd_mm_yyyy = first_date
if dd_mm_yyyy.include? ', '
dd_mm_yyyy = dd_mm_yyyy.split(', ').first.strip
end
is_a_holiday = ::Studium.is_this_day_a_holiday? dd_mm_yyyy
if (Time.now - (ONE_DAY - 1)) > Time.parse(dd_mm_yyyy)
next end
expanded_lecture_line = ' '.dup
if is_a_holiday
official_holiday_string = ' [Official Holiday]'
expanded_lecture_line << crimson("#{official_holiday_string} ")
end
expanded_lecture_line << colourize_lecture_day(first_date, priority)+' '
case priority
when 1 expanded_lecture_line << orange(
(name_of_the_lecture+' '+chocolate(lecture_type)).ljust(@pad_to_the_right)
)+' '+colourized_priority(priority, :honour_priority_value)
else
expanded_lecture_line << darkorange(
(name_of_the_lecture+' '+chocolate(lecture_type)).ljust(@pad_to_the_right)
)+' '+colourized_priority(priority, :honour_priority_value) end
e expanded_lecture_line
}; e
end
|
#show_thursday? ⇒ Boolean
74
75
76
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 74
def show_thursday?
@array_show_these_days.include? :thursday
end
|
#show_tuesday? ⇒ Boolean
60
61
62
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 60
def show_tuesday?
@array_show_these_days.include? :tuesday
end
|
#show_wednesday? ⇒ Boolean
67
68
69
|
# File 'lib/studium/utility_scripts/week_parser/show.rb', line 67
def show_wednesday?
@array_show_these_days.include? :wednesday
end
|
#this_weekday_is_today?(name_of_the_day) ⇒ Boolean
#
this_weekday_is_today?
#
360
361
362
363
364
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 360
def this_weekday_is_today?(name_of_the_day)
weekday_today = english_weekday?
name_of_the_day.start_with?(weekday_today)
end
|
#try_to_infer_the_name_of_the_lecture_from_this_line(line) ⇒ Object
#
try_to_infer_the_name_of_the_lecture_from_this_line
This method will attempt to guess the name of the lecture, based on a line that is stored in the file 'exams.yml'.
#
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
# File 'lib/studium/utility_scripts/week_parser/misc.rb', line 259
def try_to_infer_the_name_of_the_lecture_from_this_line(line)
result = ''.dup
regex_for_lva_id = /\d{4}, (\d{1,3}\.?\d{1,3})/
line =~ regex_for_lva_id
lva_id = $1.to_s.dup
scanned = dataset_lecture_information?.select {|name_of_the_lecture, inner_hash|
name_of_the_lecture.start_with? lva_id
}
if scanned.size == 1 result << scanned.keys.first
else
most_likely_lecture_name = @upcoming_exams_dataset.return_most_likely_lecture_name_from_this_line(line)
if lva_id[2,1] == '0' new_lva_id = lva_id.dup
new_lva_id[2,1] = '1'
scanned = dataset_lecture_information?.select {|name_of_the_lecture, inner_hash|
name_of_the_lecture.start_with? new_lva_id
}
unless scanned.empty?
scanned = dataset_lecture_information?.select {|name_of_the_lecture, inner_hash|
name_of_the_lecture.include? most_likely_lecture_name
}
result << scanned.keys.first unless scanned.empty?
end
else
if scanned.size == 0
e swarn('DEBUG! No results were found. This is not good.')
e 'The line that was faulty, was: '+sfancy(line)
else new_selection = scanned.select {|key, value|
key.include? most_likely_lecture_name
}
if new_selection.empty?
e swarn('DEBUG! We found ')+sfancy(scanned.size.to_s)+
swarn(' results. This has to be NARROWED DOWN to '\
'only one entry. (March 2018)')
else
result << new_selection.keys.first unless new_selection.empty?
end
end
end
end
return result.strip
end
|