capitalize room name

This commit is contained in:
Mylloon 2022-08-30 22:59:04 +02:00
parent 20fd40bbba
commit cdec3c6309
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 19 additions and 8 deletions

View file

@ -4,7 +4,7 @@ use scraper::{Html, Selector};
use std::collections::HashMap;
use crate::utils::{
self,
self, capitalize,
models::{Position, TabChar},
};
@ -85,12 +85,14 @@ pub async fn timetable(
}
None => None,
},
room: course
.select(&sel_strong)
.next()
.unwrap()
.inner_html()
.replace("<br>", ""),
room: capitalize(
&mut course
.select(&sel_strong)
.next()
.unwrap()
.inner_html()
.replace("<br>", ""),
),
start: location_tracker,
size: match course.value().attr("colspan") {
Some(i) => i.parse().unwrap(),

View file

@ -75,7 +75,7 @@ pub fn line_table(
Some(text) => {
println!("{:^cell_length$}{}", text, rsbc_bbc);
last_day = true;
},
}
None => (),
}
} else {
@ -114,3 +114,12 @@ pub fn split_half(text: &str) -> (&str, &str) {
pub fn etc_str(text: &str) -> String {
format!("{}...", split_half(text).0.trim())
}
// Capitalize string
pub fn capitalize(text: &mut str) -> String {
if let Some(r) = text.get_mut(0..1) {
r.make_ascii_uppercase();
}
text.to_string()
}