Some refactor, better texts, and fixing some issues

This commit is contained in:
2023-05-20 00:05:05 +02:00
parent f7a7b85111
commit baa19a4319
3 changed files with 71 additions and 59 deletions
+22
View File
@@ -0,0 +1,22 @@
pub struct CurrentWeather {
current_weather: serde_json::Value,
clean: bool,
}
impl CurrentWeather {
pub fn new(current_weather: serde_json::Value, clean: bool) -> CurrentWeather {
CurrentWeather {
current_weather,
clean,
}
}
pub fn extract_data(&self, data_name: &str, data_description: &str) -> String {
let data = &self.current_weather[data_name];
if self.clean {
format!("{data}")
} else {
format!("{data_description}: {data}")
}
}
}