Some refactor, better texts, and fixing some issues
This commit is contained in:
@@ -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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user