crate::ix!();
#[derive(Getters,Debug)]
#[getset(get="pub")]
pub struct AccountHistogram {
strategy: HistogramDisplayStrategy,
months: Vec<HistogramMonth>,
}
impl AccountHistogram {
pub fn new(strategy: &HistogramDisplayStrategy) -> Self {
Self {
strategy: strategy.clone(),
months: vec![],
}
}
pub fn push(&mut self, histogram_month: HistogramMonth) {
self.months.push(histogram_month);
}
}
impl fmt::Display for AccountHistogram {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for month in &self.months {
month.fmt_with(f, &self.strategy)?;
if month != self.months.last().unwrap() {
writeln!(f, "________________________________")?;
} else {
writeln!(f, " ")?;
}
}
write!(f, "")
}
}